bwencadtutor Posted April 15, 2009 Posted April 15, 2009 Help needed! In Model Space, there are many block instances with different attributes value of one block reference, how can I identify each instance ? I am trying to list all attributes value of each instance of this one block reference. Thanks Bing Quote
Lee Mac Posted April 15, 2009 Posted April 15, 2009 I would just use something like this: (defun c:getatts (/ bdef blk ss att aLst attLst) (vl-load-com) (setq bdef (getvar "INSNAME")) (while (not blk) (setq blk (getstring t (strcat "\nSpecify Block to be Searched <" bdef ">: "))) (cond ((eq "" blk) (setq blk bdef)) ((and (snvalid blk) (tblsearch "BLOCK" blk))) (T (setq blk nil bdef "")))) (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 blk) (cons 66 1) (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (foreach x (mapcar 'cadr (ssnamex ss)) (setq att (entnext x)) (while (not (eq "SEQEND" (cdadr (setq aLst (entget att))))) (setq attLst (cons (cons (cdr (assoc 2 aLst)) (cdr (assoc 1 aLst))) attLst) att (entnext att)))) (alert (vl-princ-to-string (reverse attLst)))) (princ "\n<!> No Blocks Found <!>")) (princ)) Will list all attributes as an associative list in the format: ( . ) Quote
Patrick_35 Posted April 16, 2009 Posted April 16, 2009 Hi You can replace this (foreach x (mapcar 'cadr (ssnamex ss)) (setq att (entnext x)) (while (not (eq "SEQEND" (cdadr (setq aLst (entget att))))) (setq attLst (cons (cons (cdr (assoc 2 aLst)) (cdr (assoc 1 aLst))) attLst) att (entnext att)))) (alert (vl-princ-to-string (reverse attLst))) by (vlax-for bl (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (setq attlst (mapcar '(lambda(x) (cons (vla-get-tagstring x) (vla-get-textstring x))) (vlax-invoke bl 'getattributes))) ) (vla-delete sel) (alert (vl-princ-to-string attlst)) @+ Quote
Lee Mac Posted April 16, 2009 Posted April 16, 2009 I would think VBA could accomplish the same, yes. Quote
bwencadtutor Posted April 16, 2009 Author Posted April 16, 2009 I tried several ways, but didn't work out. Quote
Lee Mac Posted April 16, 2009 Posted April 16, 2009 I'm sure there is someone on here who could happily supply the code, I however have little to no knowledge of VBA... 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.