Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Turn off all frozen layers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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)))
)
Civil 3D 2012 SP3 | Win 7 64-bit SP1
Xeon E5-1620 @ 3.60GHz, 16GB Ram | NVidia Quadro 600
Solved! Go to Solution.
Re: Turn off all frozen layers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: Turn off all frozen layers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Works like a charm. Thanks for the detailed explaination.
Civil 3D 2012 SP3 | Win 7 64-bit SP1
Xeon E5-1620 @ 3.60GHz, 16GB Ram | NVidia Quadro 600
