Jump to content

Freeze all layers except current, and restore previous state


freddy0663

Recommended Posts

I'm new to the the forum... and have been searching to find a lisp routine that will freeze all layers on model space (no paper space), except current, and restore previous state (no thaw all layers),

Sorry for my english

Thanks in advance

Link to comment
Share on other sites

I'm new to the the forum... and have been searching to find a lisp routine that will freeze all layers on model space (no paper space), except current, and restore previous state (no thaw all layers)

 

Firstly, welcome to CADTutor, freddy0663. :)

 

Methinks you are confusing Layers with Entities... Entities exist in Model and Paper (Layout) Space, whereas Layer exist within the Layer Collection/Dictionary Object (within the Drawing's Database), and not on a 'tab' per-se.

Link to comment
Share on other sites

Introduction..

 

Sorry, i studied france language on school. And help me for english language with internet translator (lucky), and drag and drop from another thread.

 

However this problem no stop me. I like too mutch Lisp code and Autocad program.

 

I use routine of Lee Mac, called Fa.lsp (since 2010) attached below.

First command freeze all layer except current, second command thaw all layer.

 

I search similar lisp to restore same previuos state of layers ( certain layers must be freeze like before)

 

Thanks

Freeze_Thaw_All.lsp

Link to comment
Share on other sites

Try these two commands:

 

(defun c:frz ( / d n )
   (while (setq d (tblnext "LAYER" (null d)))
       (if
           (and
               (zerop (logand 1 (cdr (assoc 70 d))))
               (not (member (setq n (cdr (assoc 2 d))) *thaw-list*))
           )
           (setq *thaw-list* (cons n *thaw-list*))
       )
   )
   (command "_.-layer" "_F" "*" "")
   (princ)
)

(defun c:unfrz ( )
   (if *thaw-list*
       (command "_.-layer" "_T"
           (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) *thaw-list*))
           ""
       )
   )
   (setq *thaw-list* nil)
   (princ)
)

Type frz to freeze all layers except the current layer and unfrz to restore the previous state.

Link to comment
Share on other sites

  • 4 months later...
Try these two commands:

 

(defun c:frz ( / d n )
   (while (setq d (tblnext "LAYER" (null d)))
       (if
           (and
               (zerop (logand 1 (cdr (assoc 70 d))))
               (not (member (setq n (cdr (assoc 2 d))) *thaw-list*))
           )
           (setq *thaw-list* (cons n *thaw-list*))
       )
   )
   (command "_.-layer" "_F" "*" "")
   (princ)
)

(defun c:unfrz ( )
   (if *thaw-list*
       (command "_.-layer" "_T"
           (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) *thaw-list*))
           ""
       )
   )
   (setq *thaw-list* nil)
   (princ)
)

Type frz to freeze all layers except the current layer and unfrz to restore the previous state.

 

Hi Lee!

 

Thank you for this tip. I find it extremely useful.

 

I noticed that I can only use it if I copy it in command line in autocad. I have to do this every time I open a file.

 

What can I do to permanently store this two commands in autocad?

 

I use Autocad 2013 for Mac.

 

Thank you!

 

Regards,

Tomaž

Link to comment
Share on other sites

Hi Tomaž,

 

Welcome to CADTutor and thank you, I'm glad you find the programs useful.

 

In response to your questions: open notepad (or the Mac equivalent of a plain text editor) and copy/paste the code into the editor.

Save the file with an arbitrary filename, but with a .lsp file extension (ensure 'Save as Type' is set to 'All Files', or whatever the equivalent is on a Mac)

 

Then, follow my tutorials for information regarding loading & automatic loading:

 

How to Run an AutoLISP Program

Loading Programs Automatically

Link to comment
Share on other sites

I'm new to the the forum... and have been searching to find a lisp routine that will freeze all layers on model space (no paper space), except current, and restore previous state (no thaw all layers),

 

 

Sorry for my english

Thanks in advance

If you set EXPERT=0 your lisp works fine.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...