So I'm missing something here. This doesn't seem to delete the 1__1 layer that is empty once I move objects over to the "Line4" layer.
Code:
(setq lay2 (ssget "x" '((8 . "1__1"))))
(setq flag (tblsearch "LAYER" "1__1"))
(if flag
(command "_change" lay2 "" "P" "layer" "LINE4" "")
(command "_purge" "LA" lay2 "n")
)
Hmmmm...maybe I should just use Laydel instead of purge.
Edit:
A little Follow up after I posted. I changed the purge to a Laydel and it works when I try it at the command line but doesn't work in the routine.
On a side note looking at this I am not sure where I'm putting the list of layers.
Code:
;;; Purge all layers except those in list
;;; Example: (ax:purge-layers (vla-get-activedocument (vlax-get-acad-object)) '("DIM" "LAYER1"))
;;; Argument: doc {document}
;;; name {a layer name list}
(defun ax:purge-layers (doc except)
(vlax-for item (vla-get-layers doc)
(setq ln (vla-get-name item))
(if (not (member (strcase ln) except))
(purge-layer ln)
)
)
)
J. Logan
ACAD 2016