jim78b Posted January 18 Posted January 18 (edited) (defun c:exportblocks (/ blk blks x dir) (vl-load-com) (if (setq blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (progn (setvar 'filedia 0) (setq dir (strcat (getvar 'dwgprefix) "_ExportedBlocks\\")) (vl-mkdir dir) (vlax-for blk blks (if (and (not (wcmatch (setq x (vla-get-name blk)) "*|*,*`**")) (= (vla-get-isxref blk) :vlax-false) ) (command "._-wblock" (strcat dir x) x) ) ) (setvar 'filedia 1) ) ) (princ) ) hello i have this routine but autocad convert the dwg in an old previously release. i want a lisp please that convert all the blocks to separate files and then automatically convert to xrefs. Edited January 18 by SLW210 Added Code Tags! Quote
SLW210 Posted January 18 Posted January 18 Please use Code Tags, not Quote Tags for code. AFAIK, WBLOCK uses whatever you have set in Options>Open and Save>Save as for the release it uses. 1 1 Quote
Steven P Posted January 18 Posted January 18 Didn't like the way the code tag was looking..... (defun c:exportblocks (/ blk blks x dir FileDia_Old) (vl-load-com) (if (setq blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (progn (setq FileDia_Old (getvar 'filedia)) (setvar 'filedia 0) (setq dir (strcat (getvar 'dwgprefix) "_ExportedBlocks\\")) (vl-mkdir dir) (vlax-for blk blks (if (and (not (wcmatch (setq x (vla-get-name blk)) "*|*,*`**")) (= (vla-get-isxref blk) :vlax-false) ) ; end and (command "._-wblock" (strcat dir x) x) ) ; end if ) ; end vlax-for (setvar 'filedia Filedia_Old) ) ; end progn ) ; end if (princ) ) I haven't tested this yet, does this save the blocks as separate files OK as it is, and you just need to insert them as xrefs? Quote
Steven P Posted January 18 Posted January 18 So I guess if you look at the existing xref you selected you might find it is say, an AutoCAD 2018 format file and the new xref you are saving might be an AutoCAD 2024 format file. Files are backwards compatible generally (so 2024 will open a 2018 file) but not necessarily forward compatible (so 2018 might not open a 2024 file) - I think the warning is there in case others use the xref with older versions of AutoCAD. You can check - I think this works - open the existing file and type 'version' in the command line to get its current version, and then compare that to the settings as SLW210 suggests Quote
jim78b Posted January 18 Author Posted January 18 (edited) Ok thanks but is annoying this message. I have acad2023 and can open this files.i create this ext ref with lisp! Edited January 18 by jim78b Quote
Steven P Posted January 18 Posted January 18 if it is only you that uses the xref, or if everyone has the same version of CAD, I'd be tempted to open and save as a new revision 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.