harilalmn Posted August 31, 2011 Share Posted August 31, 2011 Hi All, Is there a way to select all instances of a dynamic block in the drawing by picking one? This is an attempt to "Select by name". But dynamic blocks kills my code below as they have fancy naming (Like *U24) So far I am here... (defun c:SB () (setq TargEnt (car (entsel "\nSelect block : "))) (setq blkname (EffectiveName TargEnt)) (setq ss (ssget "_X" (list (cons 0 "insert")(cons 2 blkname)))) (sssetfirst nil ss) (princ) ) ;Code below is the courtesy of 'irneb' on http://forums.augi.com/showthread.php?t=114752 (defun EffectiveName (en / ed d1 d2 d3 br) (setq ed (entget en)) (setq d1 (entget (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") ed))))) (setq d2 (entget (cdr (assoc 360 (member '(3 . "AcDbBlockRepresentation") d1))))) (setq d3 (entget (cdr (assoc 360 (member '(3 . "AcDbRepData") d2))))) (setq br (entget (cdr (assoc 340 d3)))) (cdr (assoc 2 br)) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 31, 2011 Share Posted August 31, 2011 Select your single block instance, and extract the block's name, then create a selection set of all blocks with that, or annonymous names. Next iterate through that selection set and check for matches against the original block's EffectiveName and IsDynamicBlock Properties. Sample: ... (setq ss (ssget "x" (list (cons 2 "[color=red]<BlockName>[/color],`*U*")))) ... HTH Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 31, 2011 Share Posted August 31, 2011 This post demonstrates two methods to acquire a SelectionSet of the required blocks. This may also help with regards to the Effective Block Name. Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 31, 2011 Share Posted August 31, 2011 Just for completeness... http://www.theswamp.org/index.php?topic=39260.0 Quote Link to comment Share on other sites More sharing options...
irneb Posted September 2, 2011 Share Posted September 2, 2011 Or look at the code in my "old" SelSimilar function here: http://www.augi.com/forums/showthread.php?p=827641 Quote Link to comment Share on other sites More sharing options...
gilsoto13 Posted September 7, 2011 Share Posted September 7, 2011 I made the same question long ago... I couldn't remember who helped me then... (defun c:sb (/ e name n out ss x rjp-getblockname) (vl-load-com) (prompt "\n Pick BLOCK to acquire its instances in the drawing...") (defun rjp-getblockname (obj) (if (vlax-property-available-p obj 'effectivename) (vla-get-effectivename obj) (vla-get-name obj) ) ) (if (setq x (ssget '((0 . "INSERT"))) x (ssname x 0) name (rjp-getblockname (vlax-ename->vla-object x)) ss (ssget "_X" '((0 . "INSERT"))) n -1 out (ssadd) ) (while (setq e (ssname ss (setq n (1+ n)))) (if (= (rjp-getblockname (vlax-ename->vla-object e)) name) (ssadd e out) ) ) ) (sssetfirst nil out) (princ) ) Quote Link to comment Share on other sites More sharing options...
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.