Jaap Marchal Posted February 14, 2011 Posted February 14, 2011 Hello, is there a lisp that shows or lists a block containning an embedded block. The embedded must be in a block but is somehow not visable (layer on/off, visual states etc etc) Example: I have a drawing with more than 40 blocks and i want to know wich block contains the block "BIS". Problem is that the drawing was created by a 3rd part company. We know that the block (BIS) is used. After purge all, the block is stil in the insert block list. Thanks Quote
Jaap Marchal Posted February 15, 2011 Author Posted February 15, 2011 We found the embedded block. It was on a visability state. We saved all the blocks with the lisp WBLOCKALL en open all the blocks.And there it was. So this is one way to find a embedded block, other one is open the block in blockeditor eand enlarge it en fill it with hatch. But is there a other way to find it, with lisp?, Saves a lot of time. Jaap M. BMELDER.dwg Quote
pBe Posted February 16, 2011 Posted February 16, 2011 We found the embedded block. It was on a visability state. We saved all the blocks with the lisp WBLOCKALL en open all the blocks.And there it was. So this is one way to find a embedded block, other one is open the block in blockeditor eand enlarge it en fill it with hatch. But is there a other way to find it, with lisp?, Saves a lot of time. Jaap M. I cant open your file (still stuck with R2009) Try this: (defun pBe:searchme (blk / adoc ss blk_ent ) (vl-load-com) (foreach blks (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "INSERT"))))) (setq blk_ent (tblobjname "block" (setq ss (vla-get-effectivename (vlax-ename->vla-object blks))))) (while (setq blk_ent (entnext blk_ent)) (if (and (eq (cdr (assoc 0 (entget blk_ent))) "INSERT") (eq (strcase (cdr (assoc 2 (entget blk_ent)))) (strcase blk)) ) (princ (strcat "\nBlock " blk " found inside " ss )) ) ) ) (princ) ) USAGE: command: (PBE:SEARCHME "EmbeddedBlcokName") Block EmbeddedBlcokName found inside THIS_BLOCK Block EmbeddedBlcokName found inside THAT_BLOCK It only works if the block is nested only once, but it can be easily modified to look for nested blocks within a block. Hope this helps Quote
Lee Mac Posted February 16, 2011 Posted February 16, 2011 (edited) Some fun: (defun c:BlockHierarchy ( / _blockhierarchy blocks ) (vl-load-com) ;; © Lee Mac 2011 (defun _blockhierarchy ( block indent / _name ) (defun _name ( obj ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name) ) ) (princ "\n") (repeat indent (princ " ")) (princ "|--> ") (princ (_name block)) (vlax-for obj block (if (eq "AcDbBlockReference" (vla-get-ObjectName obj)) (_blockhierarchy (vla-item blocks (_name obj)) (1+ indent)) ) ) ) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for block blocks (if (and (eq :vlax-false (vla-get-isXref block)) (eq :vlax-false (vla-get-isLayout block)) ) (_blockhierarchy block 1) ) ) (princ) ) Edited February 16, 2011 by Lee Mac Quote
Jaap Marchal Posted February 16, 2011 Author Posted February 16, 2011 Some fun: (defun c:BlockHierarchy ( / _blockhierarchy blocks ) (vl-load-com) ;; © Lee Mac 2011 (defun _blockhierarchy ( block indent / _name ) (defun _name ( obj ) (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename) 'effectivename 'name) ) ) (princ "\n") (repeat indent (princ " ")) (princ "|--> ") (princ (_name block)) (vlax-for obj block (if (eq "AcDbBlockReference" (vla-get-ObjectName obj)) (_blockhierarchy (vla-item blocks (_name obj)) (1+ indent)) ) ) ) (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for block blocks (if (and (eq :vlax-false (vla-get-isXref block)) (eq :vlax-false (vla-get-isLayout block)) ) (_blockhierarchy block 1) ) ) (princ) ) Yes yes, Wow Lee, you did it again. Tanks, Jaap 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.