Not applicable
01-27-2020
06:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a routine written to loop through all of my layers on my drawing. I'm trying to have it move the items to another layer or delete them if they are on a certain layer. I have the if statements set up properly, but I cannot figure out the change or erase commands.
Here is the code I currently have - I have it set up to princ on each layer what I would like it to do so I could make sure it does the right thing:
(defun c:testmacro () (setvar 'CLAYER "0") (setq layer (tblnext "LAYER" T)) (while layer (if (= (substr (cdr (assoc 2 layer)) 1 2) "D-") (progn ;ERASE ALL ITEMS ON LAYER (princ (strcat "\nDelete items on " (cdr (assoc 2 layer)))) ) (progn (if (= (substr (cdr (assoc 2 layer)) 1 2) "P-") (progn ;CHANGE LAYER FROM P- TO E- (princ (strcat "\nMove from " (cdr (assoc 2 layer)))) (princ (strcat " to "P-" (substr (cdr (assoc 2 layer)) 3))) ) (progn ;OTHERWISE DO NOTHING ) ) ) ) (setq layer (tblnext "LAYER")) ) )
I've tried using (ssget "_X" '((8 . (cdr (assoc 2 layer))))) to select all of the items on the layer in the CHPROP/CHANGE and ERASE commands but I get an error stating "bad SSGET list value".
Solved! Go to Solution.
Link copied