Message 1 of 18
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to get the below code to work and I am not having any luck.
I think it could be an issue with wcmatch because I am using #.
I need to be able to change the values of the tags for all the blocks that are in a particular drawing.
So I tried to enter " * " for all blocks.
Then I have tag named "ITEM %" (This name can change, but this is the name in this example) and I use "ITEM\u+0020%" if that matters.
The old value is # and the new value will be %.
(defun changeAttribValue (ent atttag oldval newval / entl) (while (and ent (/= "SEQEND" (cdr (assoc 0 (setq entl (entget ent)))))) (and (= atttag (cdr (assoc 2 entl))) (= oldval (cdr (assoc 1 entl))) ;<- could use WCMATCH instead (entmod (subst (cons 1 newval) (assoc 1 entl) entl)) (entupd ent) (mapcar 'princ (list "\n" oldval " -> " newval)) ) (setq ent (entnext ent)) ) ) (defun C:CHATTRIB2 (/ ss a attag bname oldval newval) (and (/= "" (setq bname (getstring "\nBlock name: "))) (/= "" (setq tag (getstring T "\nFind Tag: "))) (/= "" (setq value (getstring T "\n:With Value: "))) (/= "" (setq attag (getstring T "\nTag: "))) (/= "" (setq oldval (getstring T "\nOld value: "))) (/= "" (setq newval (getstring T "\nNew value: "))) (setq a 0 ss (ssget "X" (list '(0 . "INSERT") '(66 . 1) (cons 2 bname))) ) (repeat (sslength ss) (changeAttribValue (ssname ss a) attag oldval newval) (setq a (1+ a)) ) ) )
Thanks,
Solved! Go to Solution.