layer states function

Jamie Duncan

Usenet Archive
Joined
Jun 27, 2003
Messages
177
Reaction score
0
Trying to save and restore layer states within lisp routines. Came up with these - seems to store 'em just fine, but doesn't seem to be able to restore them...any help is appreciated:

(defun c:savealllayers (/ end1 temp )
(setq Savethelayers nil temp T)
(while (setq end1 (tblnext "LAYER" temp))(princ end1)
(setq temp nil
Savethelayers (cons (list (cdr (assoc 2 end1))(cdr (assoc 70 end1))(cdr (assoc 62 end1))) Savethelayers)) )
)

(defun c:Restorealllayers (/ temp layval1 laynam1 layval2) (foreach temp Savethelayers (setq laynam1 (car temp) layval1 (cadr temp) layval2 (caddr temp)) (if (tblsearch "LAYER" laynam1) (progn (if (< 0 layval2)(command "-layer" "off" laynam1 "")(command "-layer" "on" laynam1 "")) (if (logand layval1 1)(command "-layer" "f" laynam1 "")(command "-layer" "t" laynam1 "")) (if (logand layval1 4)(command "-layer" "lo" laynam1 "")(command "-layer" "u" laynam1 "")) ) ) )
)

Jamie Duncan

Consulting - If you're not part of the solution, there's good money in prolonging the problem.
 
try this:

(defun c:Restorealllayers (/ temp layval1 laynam1 layval2) (foreach temp Savethelayers (setq laynam1 (car temp) layval1 (cadr temp) layval2 (caddr temp)) (if (tblsearch "LAYER" laynam1) (progn (if (< 0 layval2) (command "_-layer" "on" laynam1 "") (command "_-layer" "off" laynam1 "")) (if (logand layval1 1) (command "_-layer" "t" laynam1 "") (command "_-layer" "f" laynam1 "")) (if (logand layval1 4) (command "_-layer" "u" laynam1 "") (command "_-layer" "lo" laynam1 "")) ) ) )
)

I think you had the condition backwards, the above wored for me.

bobb
 
Whoops, I sent it too soon. Doesn't owrk in some instances. . . . .

bobb
 
Hey Luis! Mon amour Espagnol!

I truly don't understand vlisp! (it's a birth defect)
I'm not sure why my function doesn't work. Can you 'splain why? (still angry that entmod doesn't work on "layers" or ignores code 70)

Jamie
 
k' like i'm confused. Why doesn't this work?

I thinks it's a variable thing!

Like for some reason it doesn't recognize caddr temp as an integer?

Why oh why?

I could solve it another way, but this started out so elegant!

GRRRRRRRR! Lisp!

Jamie
 
Jamie,
The functions Luis posted are the way to go. Take a look at a thread titled "Layer States w\ F keys". I posted a similar set of functions as Luis with an example at the end. Here are some way's to use Luis' functions:

To save the current Layer State
(set-layerstate "MyLayerState" acLsAll) ;where acLsAll will save all the Layers properties; On Freeze Color etc.

To restore a saved Layer State
(if (member "MyLayerState"(get-statenames))(restore-layerstate "MyLayerState"))

HTH

jb
 

Latest threads

Back
Top