Jump to content

Covert all blocks & blocks inside blocks to '0' layer excluding other entity


ctrlaltdel

Recommended Posts

Have many blocks & blocks within blocks that we need to convert to '0' layer excluding other entity such as lines,circles,text,dimensions.....inside this blocks.

 

Google and found many lisp & but never one that convert only blocks.

 

Please assists.

Link to comment
Share on other sites

What u mean convert block to 0?

 

Sent from my Lenovo PB1-770M using Tapatalk

 

Meaning change the blocks & only blocks & blocks within blocks to layer '0'

Link to comment
Share on other sites

OK...after one eliminates all geometry, all text and all dimensions what's left of a block?

 

Can you provide us with a copy of one of these mystery blocks? An actual .dwg file not an image file.

Link to comment
Share on other sites

(defun C:LAY0 ( / acdoc) (vl-load-com)
 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 (vlax-for blk (vla-get-blocks acdoc)
   (vlax-for obj blk
   (if
     (eq (vla-get-objectname obj) "AcDbBlockReference")
     (vla-put-layer obj "0")
     )
   )
 )
 (vla-regen acdoc acAllViewports)
 (princ)
 )

Link to comment
Share on other sites

OK...after one eliminates all geometry, all text and all dimensions what's left of a block?

 

Can you provide us with a copy of one of these mystery blocks? An actual .dwg file not an image file.

 

Hi Remark. nothing particular regarding the blocks. The purpose is we need to delete some entity of some layers using a 'layer delete' lisp routine. Unfortunately some blocks are in that layer, which will get deleted until we can change them all to layer '0'

Link to comment
Share on other sites

U dont need kisp for that. Just filter selection

 

Sent from my Lenovo PB1-770M using Tapatalk

 

Unable to since there are may levels of blocks within blocks

Link to comment
Share on other sites

(defun C:LAY0 ( / acdoc) (vl-load-com)
 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 (vlax-for blk (vla-get-blocks acdoc)
   (vlax-for obj blk
   (if
     (eq (vla-get-objectname obj) "AcDbBlockReference")
     (vla-put-layer obj "0")
     )
   )
 )
 (vla-regen acdoc acAllViewports)
 (princ)
 )

 

hi Stefan. Tested on a small dwg & it works. WIll test on actual dwg soon. Feedback soon. thank again.

Link to comment
Share on other sites

hi Stefan. Tested on a small dwg & it works. WIll test on actual dwg soon. Feedback soon. thank again.

OK, great...

You might want to filter out Xrefs, Xref's blocks, dim definitions and more...

(defun LAY0 ( / acdoc) (vl-load-com)
 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 (vlax-for blk (vla-get-blocks acdoc)
   (if
     (and
       (eq (vla-get-isxref blk) :vlax-false)
       (not (wcmatch (vla-get-name blk) "*|*,`*[EADX]*"))
     )
     (vlax-for obj blk
       (if
         (eq (vla-get-objectname obj) "AcDbBlockReference")
         (print (vla-get-name obj))
       )
     )
   )
 )
 (vla-regen acdoc acAllViewports)
 (princ)
)

Link to comment
Share on other sites

Stefan. Your first code works well for my work. Really is life saver. Will try your other code when time permits. Thanks

Link to comment
Share on other sites

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...