Automatically Thaw All Layers Changing From Tilemode 1 To 0

Automatically Thaw All Layers Changing From Tilemode 1 To 0

Anonymous
Not applicable
1,095 Views
5 Replies
Message 1 of 6

Automatically Thaw All Layers Changing From Tilemode 1 To 0

Anonymous
Not applicable

When I am on the Model Tab (Tilemode 1) & am using a current named layer state with some of the layers frozen (I have my Named Layer States set up to only restore the Layer Visibility Properties), upon clicking on one of my layout tabs (change to Tilemode 0), I would like a lisp routine to automatically thaw all layers (Command is LAYTHW), so my layers are frozen or thawed per viewport the way I set them up per viewport on each layout tab.

Otherwise, I have to remember to manually use LAYTHW once I am back on a layout tab. If I don't, some of my layers are globally frozen in all viewports. This can be a major headache if I forget to do this prior to plotting to a multi-page pdf file (1 layout tab per single page in the multi-page pdf file), because some of the layers on some of the layouts will be un-intentionally frozen.

 

Again, I want the LAYTHW lisp to execute when I change TILEMODE from 1 to 0.

Thanks

0 Likes
1,096 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor

I am pretty sure it can be accomplished with a reactor.  I would have to brush up by inspecting some of my old code in order to write it for you.  If I find the time (before someone else has) I will.  Be patient.  Sometimes the drive-thru window is backed up or unmanned.  I think that most people here have work and homes and families to tend which leads to limited time for their hobbies.

John F. Uhden

0 Likes
Message 3 of 6

john.uhden
Mentor
Mentor

Place the following code into your acaddoc.lsp file.

 

(defun @Tilemode_reactor (Reactor Info / Reaction Doc)
  (setq Doc (vla-get-activedocument (vlax-get-acad-object))))
  (setq Reaction (vlr-current-reaction-name))
  (cond
    ((/= (car Info) "TILEMODE"))
    ((not (cadr Info))) ; either will-change or the change was unsuccessful
    ((= Reaction :vlr-sysVarChanged)
      (and
        (= (getvar "TILEMODE") 0)
        (princ "\nTHAWING ALL LAYERS\n")
        (vlax-for Layer (vlax-get Doc 'Layers)
          (if (/= (vlax-get Layer 'Name)(getvar "clayer"))
            (vlax-put Layer 'Freeze 0)
          )
        )
      )
    )
  )
)
(if (/= (type Tilemode_reactor) 'VLR-SysVar-Reactor)
  (setq Tilemode_reactor
    (vlr-SysVar-reactor "Uhden Tilemode Reactor"
     '((:vlr-sysVarChanged . @Tilemode_reactor))
    )
  )
)

John F. Uhden

0 Likes
Message 4 of 6

john.uhden
Mentor
Mentor

OOPS!!  There is one too many closing parentheses in the 2nd line...

 

(setq Doc (vla-get-activedocument (vlax-get-acad-object))))

John F. Uhden

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks, John

 

I'll try your code. I am a lisp newbie, I have 2 lisp routines loaded as 2 separate .lsp files. So, instead of integrating your code into the acaddoc.lsp file, could I create a separate .lsp file & load that file & put it in the same path as the other 2?  Any advantage in integrating it into the acaddoc.lsp file?

0 Likes
Message 6 of 6

john.uhden
Mentor
Mentor

If you mean loading them using appload or typing in (load ...), then using acaddoc.lsp is quite an advantage because AutoCAD loads acaddoc.lsp on every drawing open or new.  A good method is to use acaddoc.lsp to (load "this") and (load "that").  It's the same as if the contents of this and that were written into the acaddoc.lsp file itself.

 

Remember that if your acaddoc.lsp file (or the files it loads) contains nothing but defuns, then the functions themselves have to be called in order to run on opening.  F'rinstance...

 

(defun goodday ()

  (alert "I hope your day is going well.")

  (princ)

)

(goodday)

 

But you don't have to do that with the function I provided.  It just needs to be defined and will run as a reaction to an event (as long as the rest of the code is loaded).

 

Clear as a dirty martini, right?  Well, at least that's clearer than a bloody mary.

John F. Uhden

0 Likes