Selecting Blocks if "xxx" specified chars included as attributes

Selecting Blocks if "xxx" specified chars included as attributes

emreakyazicigsl
Advocate Advocate
290 Views
1 Reply
Message 1 of 2

Selecting Blocks if "xxx" specified chars included as attributes

emreakyazicigsl
Advocate
Advocate

Hey everyone, I was looking for a LISP that selects blocks includes "XXX" characters as attributes among selected items. I have a LISP in here, but having problem in selecting according to chars.

 

 

(defun c:NA001 ( / tag val newlist ss i e foundTagMatch)



;;;selecting and changing first part of selection. No Problem here
(setq tag '("ATTRIBUTE_TAG_01"))
(setq val '("ATTRIBUTE_VALUE_01"))
(setq newlist (mapcar 'cons tag val))
(if (setq ss (ssget "I" '((0 . "INSERT")(66 . 1))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(foreach itm (vlax-invoke e 'GetAttributes)
(if (setq foundTagMatch (assoc (strcase (Vla-get-tagstring itm))
newlist
))(Vla-put-textstring itm (cdr foundTagMatch)))
)))(princ)







;;;selecting and changing second part of selection. No Problem here
(setq tag '("ATTRIBUTE_TAG_02"))
(setq val '("ATTRIBUTE_VALUE_01"))
(setq newlist (mapcar 'cons tag val))
(if (setq ss (ssget "I" '((0 . "INSERT")(66 . 1))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(foreach itm (vlax-invoke e 'GetAttributes)
(if (setq foundTagMatch (assoc (strcase (Vla-get-tagstring itm))
newlist
))
(Vla-put-textstring itm (cdr foundTagMatch)))
)))(princ)

;;;selecting and changing last part of selection. Need Help in here
(setq tag '("ATTRIBUTE_TAG_02"))
(setq val '("ATTRIBUTE_VALUE_02"))
(setq newlist (mapcar 'cons tag val))
(if (setq ss (ssget "I" '((0 . "INSERT")(66 . 1)))) ;in here, i need to select "XXX" included attribute values
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(foreach itm (vlax-invoke e 'GetAttributes)
(if (setq foundTagMatch (assoc (strcase (Vla-get-tagstring itm))
newlist
))
(Vla-put-textstring itm (cdr foundTagMatch)))
)))(princ)

)

 

0 Likes
291 Views
1 Reply
Reply (1)
Message 2 of 2

ronjonp
Advisor
Advisor

Maybe? "XXX" characters as tagNAME or tagSTRING ?

(if (wcmatch (strcase (vla-get-textstring itm)) "*XXX*")
  (vla-put-textstring itm "SOMEVALUE")
)

 

0 Likes