TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Jimmy Sean on January 30, 2013, 09:30:04 AM
-
I need to have a lisp routine that will delete all attributes in all block except for certain blocks. Those few need to stay. Also it needs little to no user input.
I found this lisp but I don't have a clue on how to add an exclusion list of block names to it. If someone could point me in the right direction it would be appriciated.
(defun celTXT (/ ss i sn x)(vl-load-com)
(if (setq ss (ssget '((0 . "INSERT") (66 . 1))))
(repeat (setq i (sslength ss))
(setq sn (ssname ss (setq i (1- i))))
(while
(not
(eq (cdr (assoc 0 (entget (setq x (entnext sn))))) "SEQEND")
)
(if (eq (cdr (assoc 0 (entget x))) "ATTRIB")
(vla-delete
(vlax-ename->vla-object (cdr (assoc -1 (entget x))))
)
)
)
)
)
(princ)
)
-
Add groupcode 2 to your filter and add the blocknames to it. Note that wildcards can be used too.
This filter will only grab blocks named blockname1, blockname2 or any block with test in it.
(setq ss (ssget '((0 . "INSERT") (2 . "blockname1,blockname2,*test*") (66 . 1))))
.... and welcome to the swamp 8-)
-
Note that you will also need to delete the attribute definitions from within the respective block definitions, else an ATTSYNC will bring all the attribute references back ;-)
Welcome to the Swamp Jimmy :-)
-
Thanks ronjonp and Lee Mac for the welcome.
ronjonp I think I understand. What you added only includes those names listed in the selection. What if I wanted to select all blocks and then exclude or remove ten block names from the selection?
Lee Mac I don't see that being an issue.
What I'm trying to accomplish is a cleanup for a client hand-off of the drawing. I need to keep room names and door tags and the like but remove the text from chairs, tables, etc..
-
Thanks ronjonp and Lee Mac for the welcome.
ronjonp I think I understand. What you added only includes those names listed in the selection. What if I wanted to select all blocks and then exclude or remove ten block names from the selection?
...
Use the "_x" part of ssget to select all.
Put a tilde in front of the names in your filter and it will exclude them.
(setq ss (ssget "_x" '((0 . "INSERT") (2 . "~blockname1,~blockname2") (66 . 1))))
-
Use the "_x" part of ssget to select all.
Put a tilde in front of the names in your filter and it will exclude them.
(setq ss (ssget "_x" '((0 . "INSERT") (2 . "~blockname1,~blockname2") (66 . 1))))
If I'm understanding correctly like this?
(if (setq ss (ssget "all" '((0 . "INSERT") (2 . "~rmnm-no,~dr-no") (66 . 1))))
-
Here is a sample drawing if it helps.
-
Change your "all" to "_x" to make sure you grab everything ... your filter looks correct.
-
Jimmy , are you still looking for a solution , or my codes worked for you as needed ? :kewl:
-
Nope you are the man thanks. Thanks Tharwat and ronjonp for the patience, guidence and help. For those interested http://www.cadtutor.net/forum/showthread.php?76958-Delete-all-attributes-except-for-certain-blocks/page2 (http://www.cadtutor.net/forum/showthread.php?76958-Delete-all-attributes-except-for-certain-blocks/page2)