Tom_D 发表于 2022-7-5 22:19:05

Turn off non-plottable layers

Anyone have a Lisp routine that will turn off all layers marked as not plottable?
 
Thanks, Tom

Lee Mac 发表于 2022-7-5 22:41:14

Try the following:

(defun c:nonplotoff ( / a e )   (while (setq a (tblnext "layer" (null a)))       (setq e (entget (tblobjname "layer" (cdr (assoc 2 a)))))       (if (zerop (cdr (assoc 290 e)))         (entmod (subst (cons 62 (- (abs (cdr (assoc 62 e))))) (assoc 62 e) e))       )   )   (princ))

Tom_D 发表于 2022-7-5 22:52:39

Excellent! even works with that pesky layer Defpoints...I see that changing "(cons 62 (- " to "(cons 62 (+ " turns the non-plot layers on.
 
Thank you Lee for all your generous Lisp help.
 
Tom

Stefan BMR 发表于 2022-7-5 23:03:07

ActiveX

(vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if   (= (vla-get-plottable layer) :vlax-false)   (vla-put-layeron layer :vlax-false)   ) )Vanila

(while (setq layer (tblnext "layer" (not layer))) (if (= 0 (cdr (assoc 290 (setq lst (entget (tblobjname "layer" (cdr (assoc 2 layer))))))))   (entmod (subst (cons 62 (- (abs (cdr (setq old (assoc 62 lst)))))) old lst))   ) )

Lee Mac 发表于 2022-7-5 23:12:58

 
You're welcome Tom
 
If you were after both options, the code could be written more concisely as:
 

(defun c:npoff nil (nonplot -))(defun c:nponnil (nonplot +))(defun nonplot ( f / a e )   (while (setq a (tblnext "layer" (null a)))       (if (zerop (cdr (assoc 290 (setq e (entget (tblobjname "layer" (cdr (assoc 2 a))))))))         (entmod (subst (cons 62 (f (abs (cdr (assoc 62 e))))) (assoc 62 e) e))       )   )   (princ))

Tom_D 发表于 2022-7-5 23:22:19

Efficiency is good... I do use both to quickly "isolate" layers (I hate that term). I use many routines to turn on/off various layers by wildcard: LO___ for off and LON__ for on.
 
Thanks again to London and Baia Mare (I visited Baia Mare in 1981 with my dance company...).
 
Tom
页: [1]
查看完整版本: Turn off non-plottable layers