Deleting Layers with Lisp

Scott

Usenet Archive
Joined
Feb 29, 2000
Messages
606
Reaction score
0
Does anybody here know how to delete a layer using lisp? The layer has nothing on it, and can be deleted, I would rather not use the purge command as it write a bunch of junk to the command line when purging a layer.

TIA

Scott
 
try this:

;; type the layer name you want to delete
(setq layer_name "a-dim")

(if (not (vl-catch-all-error-p
(setq vla_layer (vl-catch-all-apply
'vla-item
(list (vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
layer_name)))))
;; if is possible it will be deleted...
(vl-catch-all-apply 'vla-delete (list vla_layer)))

hth.
 
The layer symbol must be set to the layers collection. It is not just a magic word. ;-)

(setq layer (vla-get-layers(vla-get-activedocument(vlax-get-acad-object))))
 
Luis probably got you going. In addition, given the previous message:

(vla-delete (vla-item layer "fitting temp"))
 
This would be one way.

(vla-delete (vlax-ename->vla-object (tblobjname "layer" "layer1"))

PS: Glad you see my first post, because I sure don't.
 
Great it works now! Thanks to everybody who added their ideas!

Scott
 

Latest threads

Back
Top