PDA

View Full Version : Layer On or Off Help


vferrara
2005-06-20, 05:20 PM
Good Morning AUGI Members:

Is there a way using Autolisp to determine if a specific layer is turned "On" or "Off" on a drawing file. The layer I would need to know this information about is in an attached X-reference file.

Any assistance would be appreciated.......!!!!


Regards,
Vince

madcadder
2005-06-20, 05:48 PM
(CDR (ASSOC 62 (TBLSEARCH "LAYER" "layer-name-here")))

vferrara
2005-06-20, 06:04 PM
Tod:

Thank you for your quick response....!!!

Can I use something similar to find out if the layer is frozen or not......and then apply that to all layouts....??

madcadder
2005-06-20, 06:35 PM
Short Answer:
yes.. assoc 70

Long Answer:

Here is a copy of a new routine i have that toggles layers on/thaw or off/frozen.
It's still dirty, no variable localized, etc.
Take a look, use what you need, share the results. It should answer most questions and we'll be here for the others...

(change name of "Copy of LayerToggle.txt" to "LayerToggle.dcl")

Tod

vferrara
2005-06-20, 07:15 PM
Tod:

Once again, thank you for you help......!

I have a set of drawings that currently has one layout in paper space. The project manager wants to create two layouts and attach a different title block x-ref in each layout. After the new x-refs are attached I need to set certain layers on the new x-refs either "on" or "off" depending on how they were on the original drawing.

Below is a small sample of code that I am using, and what is happening is that the layer conditions on one on the new layouts is being set correctly but on the other new layout it is not being set correctly.

;;;;;;;;;;;;;;;;;;Start
;;;;;;
;;;;;;LAYER CHECK
;;;;;;
(setq Lstat (cdr (assoc 70 (tblsearch "layer" "4069-x-title|s-notes"))))

;;;;;;
;;;;;;SETUP LAYOUTS AND XREFS
;;;;;;

(Command "-Layout" "Rename" "layout1" "Permit")

(Command "-Xref" "detach" "4069-X-Title")

(Command "-Layout" "copy" "Permit" "Contract")

;;;;;;
;;;;;;PERMIT LAYOUT
;;;;;;
(Command "-Layout" "Set" "Permit")

(Command "-LAYER" "S" "0" "")

(Setq DtitP "F:\\Projects\\4069\\DWGS\\Xref\\4069-X-Title.dwg")
(Command "-XREF" "A" DtitP "0,0" "1" "1" "0")
(Command "ZOOM" "E" )
(If (= Lstat 48) (Command "-layer" "thaw" "4069-X-Title|S-notes" ""))
(If (= Lstat 49) (Command "-layer" "freeze" "4069-X-Title|S-notes" ""))

;;;;;;
;;;;;;CONTRACT LAYOUT
;;;;;;
(Command "-Layout" "Set" "Contract")

(Command "-LAYER" "S" "0" "")

(Setq DtitP "F:\\Projects\\4069\\DWGS\\Xref\\4069-X-Title-Contract.dwg")
(Command "-XREF" "A" DtitP "0,0" "1" "1" "0")
(Command "ZOOM" "E" )
(If (= Lstat 48) (Command "-layer" "thaw" "4069-X-Title|S-notes" ""))
(If (= Lstat 49) (Command "-layer" "freeze" "4069-X-Title|S-notes" ""))

;;;;;;;;;;;;End

Can you see why only one of the new layouts is properly updating the layer information and not the other...??

Your assistance would be appreciated.

Regards,
Vince

madcadder
2005-06-20, 08:16 PM
On the bad layout... what is the "Lstat" variable set to if you type:
!Lstst
at the command line?

vferrara
2005-06-20, 09:26 PM
Tod:

!Lstat is equal to 49 on both layouts

madcadder
2005-06-20, 10:02 PM
I mirrored your code to my system and all works well.
I started a new drawing, erased LAYOUT 2, Xrefed in the titleblock, froze layer, and ran this code:

(DEFUN c:test ()
(SETQ lstat (CDR (ASSOC 70 (TBLSEARCH "layer" "new|titleblock"))))
(COMMAND "-Layout" "Rename" "layout1" "Permit")
(COMMAND "-Xref" "detach" "new")
(COMMAND "-Layout" "copy" "Permit" "Contract")
;;;;;;
;;;;;;PERMIT LAYOUT
;;;;;;
(COMMAND "-Layout" "Set" "Permit")
(COMMAND "-LAYER" "S" "0" "")
(SETQ dtitp "c:\\autocad 2002\\tods working files\\new.dwg")
(COMMAND "-XREF" "A" dtitp "0,0" "1" "1" "0")
(COMMAND "ZOOM" "E")
(IF (= lstat 48)
(COMMAND "-layer" "thaw" "new|titleblock" "")
)
(IF (= lstat 49)
(COMMAND "-layer" "freeze" "new|titleblock" "")
)
;;;;;;
;;;;;;CONTRACT LAYOUT
;;;;;;
(COMMAND "-Layout" "Set" "Contract")
(COMMAND "-LAYER" "S" "0" "")
(SETQ dtitp "c:\\autocad 2002\\tods working files\\new.dwg")
(COMMAND "-XREF" "A" dtitp "0,0" "1" "1" "0")
(COMMAND "ZOOM" "E")
(IF (= lstat 48)
(COMMAND "-layer" "thaw" "new|titleblock" "")
)
(IF (= lstat 49)
(COMMAND "-layer" "freeze" "new|titleblock" "")
)
)

The code did for me exactly what you need it to do. Both layouts have the same xref with the same layer frozen.

Am I understanding correctly...
your problem is that the CONTRACT layout does not freeze S-notes?