Select dynamicblock to get attributes

Select dynamicblock to get attributes

Rob67ert
Collaborator Collaborator
813 Views
1 Reply
Message 1 of 2

Select dynamicblock to get attributes

Rob67ert
Collaborator
Collaborator

Hi,

 

I would like to find in a selected rectangle a dynamicblock with a specific name (PKader) to get some attributes out of it.

I have this working for a normal block, but with a dynamic block it won’t.

 

(setq ss (ssget "W" p1 p3 (list '(-4 . "<AND") (cons 2 "`*U*,DynBlock") (cons 2 "PKader") '(-4 . "AND>")) ))

 

Is there a way to get this to work?

 

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
814 Views
1 Reply
Reply (1)
Message 2 of 2

ВeekeeCZ
Consultant
Consultant

You need to use an "effectivename"... see the example

 

(vl-load-com)

(defun c:SelBlocks ( / bn ss i sn)
  (if (and (setq bn (getstring "Block name: "))
	   (setq ss (ssget "_X" (list '(0 . "INSERT")
				      (cons 2 (strcat "`*U*," bn))))))
    (repeat (setq i (sslength ss))
      (if (not (wcmatch (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
	(ssdel sn ss))))
  (if ss (sssetfirst nil ss))
  (princ)
)
0 Likes