Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LAYISO to freeze layers instead of turn them off

8 REPLIES 8
Reply
Message 1 of 9
RChalmers2
6301 Views, 8 Replies

LAYISO to freeze layers instead of turn them off

How would I get LAYISO to freeze not turn off layers I do not want to see?
I did this in AutoCAD 2006 but recently upgraded to 2014 and do not remember how I did it.

Thanks

8 REPLIES 8
Message 2 of 9
phanaem
in reply to: RChalmers2

LAYFRZ freezes layers one at a time. Use LAYTHW to bring them back. I am not aware of a native AutoCAD command that act like LAYISO (select objects to keep and freeze all others layers). HTH
Message 3 of 9
RChalmers2
in reply to: phanaem

I don't believe it was a native command. i think I had to change something in a .pcp file or something or other; some file where commands are stored. Somebody told me how to do it years ago and now I do not remember how I did it.
Message 4 of 9
Kent1Cooper
in reply to: RChalmers2

Here's mine:

 

;;  LayFreezeAllBut.lsp [command name: LFAB]
;;  Freeze all Layers except those of selected objects.
;;  Kent Cooper, November 2009
;
(defun C:LFAB (/ *error* FrzLay AddLay LeaveItem ItemLay LeaveLay)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); end if
    (command)
    (command "_.undo" "_end")
  ); end defun
  (command ".undo" "begin")
  (setq FrzLay (list (cdr (assoc 2 (tblnext "layer" T)))))
  (while
    (setq AddLay (cdr (assoc 2 (tblnext "layer"))))
    (setq FrzLay (cons AddLay FrzLay))
  ); end while -- list of all Layers in drawing
  (while
    (setq
      LeaveItem (nentsel "\nSelect item on Layer to leave thawed: ")
      ItemLay (if LeaveItem (cdr (assoc 8 (entget (car LeaveItem)))))
    ); end setq
    (if (not (member ItemLay LeaveLay))
      (setq LeaveLay (cons ItemLay LeaveLay))
    ); end if
  ); end while -- list of Layers to leave thawed
  (command "_.layer" "_set" (car LeaveLay) "")
    ; in case current Layer is to be frozen, set to one to be left thawed
  (foreach LayNm LeaveLay (setq FrzLay (vl-remove LayNm FrzLay)))
  (foreach LayNm FrzLay (command "_.layer" "_freeze" LayNm ""))
  (command "_.undo" "_end")
  (princ)
); end defun
(prompt "\nType LFAB to Freeze All Layers But those of selected objects.")

 It doesn't have an equivalent to LAYUNISO, but such a thing could presumably be built.

Kent Cooper, AIA
Message 5 of 9
scot-65
in reply to: RChalmers2

(defun c:IL ( / d1 )
 (if (setq d1 (cdr (assoc 8 (entget (car (entsel
      "Isolate a Layer \nSelect an object: "))))))
  (progn
   (setvar "cmdecho" 0)
   (command ".layer" "s" d1 "f" "*" "")
   (setvar "cmdecho" 1)
   (princ (strcat "\n Layer " d1 " isolated. "))
  );progn
 );if
 (princ)
);endIL

Isolate Layer.

Stripped (no OSMODE "nea") and simplified (no layer 0 and Defpoints as part of isolation) for your use.

No unisolate provided.

From 1998.


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 6 of 9
Lee_Mac
in reply to: RChalmers2

Here's another option:

 

(defun c:layfiso ( / e l )
    (setvar 'errno 0)
    (while
        (not
            (or (= 52 (getvar 'errno))
                (and (setq e (car (entsel)))
                     (setq l (cdr (assoc 8 (entget e))))
                     (vl-cmdf "_.-layer" "_s" l "_f" (strcat "~" l) "")
                )
            )
        )
        (princ "\nMissed, try again.")
    )
    (princ)
)

 

@scot-65: be careful if the user does not select an object as (entget nil) will error.

 

Lee

Message 7 of 9
Kent1Cooper
in reply to: RChalmers2


@RChalmers2 wrote:

How would I get LAYISO to freeze not turn off layers I do not want to see?
....


As no doubt you've discovered if you've tried them out, scot-65's and Lee_Mac's routines freeze all Layers other than that of a single selected object.  That's not the way LAYISO works in the On/Off realm; it lets you pick multiple objects, keeping all of their Layer(s) on and turning off all others.  My earlier Reply here works that way for freezing, but forget that one and use the attached LayerIsolateFreezeThaw.lsp [you'll have to get it out of the .zip file] with its LIT and LUT commands.

 

A while back, I made an improved pair of commands similar to AutoCAD's LAYISO and LAYUNISO, to overcome some issues I had with them.  They're available here, where you can read my comment for a more detailed explanation of the issues and the improvements made.  Those are about On/Off condition, as LAYISO/LAYUNISO are, but it wasn't hard to adjust it [and make some other little improvements] to develop the attached, which instead of turning off the Layers not containing any of the selected objects, freezes them instead.  That command is called LIT, which stands for "Layer Isolate as to Thaw/freeze condition" [using T rather than F because the selected objects' Layers remain Thawed, and all others are frozen].  The corresponding Un-isolation command is called LUT.

 

As with LIO and LUO in that link, they work to multiple levels.  You can isolate some Layers with LIT, then if you want additional Layers frozen, isolate a smaller group, as many levels down as you want to go, and step back out of the isolations one at a time in reverse order with LUT.  That's one of the main improvements over the operation of LAYISO/LAYUNISO; you can use LAYISO multiple times, but LAYUNISO can un-isolate only the one latest group.

Kent Cooper, AIA
Message 8 of 9
JLeeSaxon
in reply to: RChalmers2

Google gave me this thread while I was trying to figure out how to make LAYISO lock, not freeze. So a tangentially-related response for anyone else who got here that way:

 

Having LAYISO lock layers is great. It allows you to CTRL+A to select and move (or whatever) your isolated objects. Either this was the default in r2014 or I accidentally changed it somehow, because I was very disappointed to install r2015 and find that LAYISO now simply hid layers, which I found quite a bit less useful.

 

Well, good news: the replies above about custom LISP and all that only applies to making LAYISO freeze. All you have to do to get LAYISO lock is click Isolate (or type LAYISO), type S for settings, and select Lock And Fade.

Lee Saxon
Ellis Photographic Design
Message 9 of 9
rhgrafix
in reply to: scot-65

Thanks! Well written, small code is good! I also wish they would add Freeze to LAYISO settings, working on a small part of  drawing when all else is frozen is way less taxing on the graphics vs turning layers off, why is that hard for so many here to understand?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost