Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Turn off all frozen layers

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
JeffPaulsen
1738 Views, 3 Replies

Turn off all frozen layers

Hi all. Let me start by saying I'm a real lisp hack.

 

I have an old routine that freezes layers that are off. I would like it to also turn off layers that are frozen. It took a while but I think I figured out how the old routine works. I was having trouble determining how the routine would know if a layer was off or not. I found if the color was a negative number that meant the layer was off  (cond ((< (dxf 62 l) 0) (command "f" (dxf 2 l)))). How do I tell if the layer is frozen?

 

I was also wondering what the character was after the DXF code ie. (dxf 62 l). Is is a lowercase L or an upper case i and what function does it have?

 

Below is the old routine that freezes layers that are off.

 

(defun c:fo (/ l dxf code list)
(defun dxf (code list)
(cdr (assoc code list))
);defun
(setq l (tblnext "layer" T))
(command "LAYER")
(while l
(cond ((< (dxf 62 l) 0) (command "f" (dxf 2 l))))
(setq l (tblnext "layer"))
);while
(command "")
(setq l ())
(cond ((not (null gc)) (gc)))
)

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: JeffPaulsen


@JeffPaulsen wrote:

....

I would like it to also turn off layers that are frozen. ....

 

.... How do I tell if the layer is frozen?

 

I was also wondering what the character was after the DXF code ie. (dxf 62 l). Is is a lowercase L or an upper case i and what function does it have?

....

(cond ((< (dxf 62 l) 0) (command "f" (dxf 2 l))))
....


The DXF 70 value for the Layer in the Layer table contains the 1 bit if the Layer is Frozen.  That entry also holds other information about it [locked, Xref-dependent, etc.] in other possible binary bits making up the value, so you can't check for a particular value, but need to check whether 1 is a part of the binary makeup of it.

 

The l is a lower-case L [you can test that by copying it out and pasting it into something with a font that makes the difference obvious].  It is the name of a variable that holds the Layer table data for each Layer as the routine steps through, and the (dxf) subroutine gives the value associated with a particular DXF code in that list.  You could add a condition like this:

 

(cond

  ((< (dxf 62 l) 0) (command "f" (dxf 2 l))); your original to freeze if turned off

  ((= (logand (dxf 70 l) 1) 1) (command "of" (dxf 2 l))); turn off if frozen

); end cond

 

The (logand) function will return 1 if the Layer is frozen, because 1 as a binary bit is part of the makeup of the DXF 70 entry.  So it will be determined to equal 1, and the Freeze option will be applied to that Layer [the Layer name is the DXF 2 value].

 

One nice thing about using (cond) is that it only looks through possible conditions until one is satisfied.  So if it finds a Layer off under the first condition and freezes it, it won't look at the second condition, whether it's frozen.  It doesn't need to, because if it was frozen by the first condition, then it will already be off.  But if it wasn't off, the first condition won't have been satisfied, so it will check whether it's frozen, and if so, turn it off.

Kent Cooper, AIA
Tags (1)
Message 3 of 4
JeffPaulsen
in reply to: Kent1Cooper

Works like a charm. Thanks for the detailed explaination.

Jeff Paulsen
Civil 3D 2020.4 | Win 10 Pro N 64-bit
Xeon W-2223 @ 3.60GHz, 32GB Ram | NVidia Quadro P2200
Message 4 of 4
shipman
in reply to: JeffPaulsen

I am looking for some help with a lisp routine and this is the routine is the closest thing that I have found. I would like to do a viewport freeze on the current viewport for only the layers that are off. In particular doing this manually throught the layer manager I first sellect all of the layers and then thaw the viewport freeze, then through a filter select all of the off layers and the viewport freeze them. I do this a lot and if I could get a lisp routine that would do this via shortcut or icon would be very helpful. I only know the basics for lisp and would like a little help modifing this code if possible.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost