Simple layer creation and checking for freeze / thaw

Simple layer creation and checking for freeze / thaw

johnw
Collaborator Collaborator
716 Views
2 Replies
Message 1 of 3

Simple layer creation and checking for freeze / thaw

johnw
Collaborator
Collaborator

I'm trying to complete a simple 3 layer creation lisp routine (Layer A B C) that will create the layers, set the colors and then freeze the other two layers. If I Type A, B and C Freeze. If I type B, A and C Freeze, etc. Problem is when the layers are already created and two layers are froze, I'm struggling with the lisp routine to check to see if layers are froze and if so, thaw accordingly. I haven't written any code of many years and this should be simple, but it's kicking my butt. Below is the basic make layer portion for A. B and C are similar and easy to accomplish. It's adding in the thawing (if fronzen), setting layer, and freezing other layers that is my problem.

 

(DEFUN C:A()
(command "-layer" "m" "A" "C" "135" "" "")
(command "-layer" "m" "B" "C" "150" "" "")
(command "-layer" "m" "C" "C" "230" "" "")
(command "-layer" "s" "A" "F" "B,C" "")
(PRIN1)
)

 

Any help would be appreciated.

0 Likes
Accepted solutions (1)
717 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

You can combine all of this into one Layer command [just hold off the final closing Enter "" until all options are done]....

 

Since you can't use the Make option with a Layer name that exists but is Frozen [because it can't be made current as the Make option does], you can just Thaw all the Layer names first, and it won't care whether they exist yet -- a message will go by that it didn't find them [or some of them], but it will just return to the base prompt and continue.  And if you Make the particular command's Layer last, it will become current, so you don't need the Set option.

 

(defun C:A ()
  (command "_.layer"

    "_thaw" "A,B,C"

    "_make" "B" "_color" "150" ""

    "_make" "C" "_color" "230" ""
    "_make" "A" "_color" "135" ""

    "_freeze" "B,C" ""

  ); command
  (princ)
); defun

Kent Cooper, AIA
Message 3 of 3

johnw
Collaborator
Collaborator
Thank Kent! couldn't be easier...for you that is... lol. thanks again and I appreciate the code.
0 Likes