Jump to content

Recommended Posts

Posted (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 by SLW210
Added Code Tags!
Posted

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.

  • Like 1
  • Thanks 1
Posted

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?

Posted

immagine.png.9e9eec1f3a0ea95ec149ff8b5e0caef6.png

 

why this message? i don't understand?

Posted

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

Posted (edited)

Ok thanks but is annoying this message. I have acad2023 and can open this files.i create this ext ref with lisp!

Edited by jim78b
Posted

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

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...