Jump to content

search for an embedded block in (dynamic) block


Recommended Posts

Posted

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

Posted

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

Posted

:)

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

Posted (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 by Lee Mac
Posted
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

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