Jump to content

Turn off non-plottable layers with Lisp


Tom_D

Recommended Posts

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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))
   )
 )

Link to comment
Share on other sites

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

 

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:npon  nil (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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...