Isolate selected layer/layers and Unisolate all that are not frozen Lisp

Isolate selected layer/layers and Unisolate all that are not frozen Lisp

Jrooker06
Collaborator Collaborator
5,139 Views
11 Replies
Message 1 of 12

Isolate selected layer/layers and Unisolate all that are not frozen Lisp

Jrooker06
Collaborator
Collaborator

I am looking for a Lisp routine that will allow me to isolate the selected layer or to select a layer to be isolated by typing LIO and then Type something like LO to unisolate all layers. does anyone have a lisp routine like this that works? i have looked on line but we end up having errors and they dont work.

0 Likes
Accepted solutions (1)
5,140 Views
11 Replies
Replies (11)
Message 2 of 12

Patchy
Mentor
Mentor

Define them in your ACAD.PGP for Layiso and Layuniso should work.

 

0 Likes
Message 3 of 12

steve216586
Advisor
Advisor

See attached to assign a keyboard shortcut. No need for .lisp.

 

I assigned "I" = Isolate, "II" = Unisolate, to make things go quickly when using those two commands.

"No one can make you feel inferior without your consent. "-Eleanor Roosevelt
0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant

@Jrooker06 wrote:

I am looking for a Lisp routine that will allow me to isolate the selected layer or to select a layer to be isolated by typing LIO and then Type something like LO to unisolate all layers. does anyone have a lisp routine like this that works? i have looked on line but we end up having errors and they dont work.


If you can't or don't want to do it with command aliases for AutoCAD's LAYISO and LAYUNISO commands as suggested, or if you want one with some improvements over those [see the comments at the link, and at the top of the file], I have made such a thing that happens to use LIO as its command name for the isolation, though it uses LUO for the unisolation.  It's available here.  And there's another one that does the same with Freezing and Thawing instead of turning Off and On.

Kent Cooper, AIA
0 Likes
Message 5 of 12

Jrooker06
Collaborator
Collaborator
Accepted solution

It was my off that wanted to make it into a lisp and use this as the standard command. So i used this for the Lisp

 

;;Isolate Selected Layer
(defun C:LIO () (C:LAYISO) (princ))

 

;;Unisolate Layers
(defun C:LO () (C:LAYUNISO) (princ))

 

This seems to work great for me but i would like to understand what everything does. Of course i understand "(defun C:LIO" and "(C:LAYISO)" but what does the rest of the code mean exactly?

0 Likes
Message 6 of 12

Kent1Cooper
Consultant
Consultant

@Jrooker06 wrote:

It was my off that wanted to make it into a lisp and use this as the standard command. So i used this for the Lisp

 

;;Isolate Selected Layer
(defun C:LIO () (C:LAYISO) (princ))

.... i would like to understand what everything does. Of course i understand "(defun C:LIO" and "(C:LAYISO)" but what does the rest of the code mean exactly?


I guess if you have those commands loaded by something like acaddoc.lsp from a shared server location, that could be a better approach than using command aliases, since the former can be applied to all computers on the network, whereas the latter would require setting the aliases on every computer separately.  [You could do it with a shared .PGP file for aliases, but that would require removing those from all individual computers, and people wouldn't be able to customize aliases for themselves independently.]

 

The first pair of parentheses after the command name is to hold any arguments and/or localized variables that are required by or used within the function or command.  In this case there aren't any, but the parentheses are still required, even if there's nothing in them.

 

The (princ) at the end is for what is referred to as "exiting quietly."  You could probably do without it in this case.  Mostly it's used so that you don't see the returned value from the last function within the routine.  For example, routines often end with resetting of some System Variables that were changed inside the routine.  If, say, it turned off command echoing by first saving the value of the CMDECHO System Variable and then setting it to 0, it would typically reset it to 1 [presumably the initial value that it saved earlier] at the end.  If that's the last thing that happens in the routine, then that 1 will be returned at the Command: prompt line when it's done.  Or if it ends with a completed (command) function that did something, that always returns nil, and the nil will show up at the Command: prompt line.  The (princ) with no arguments [or (print) or (prin1)] returns nothing at all, so it just goes back to the Command: prompt without showing something that may confuse Users who don't know how these things work.  It's only for the "look" of the command in operation at the end, but otherwise serves no operational function.

 

The right parenthesis at the very end is the mate of the left parenthesis at the very beginning -- they always need to come in pairs.

Kent Cooper, AIA
Message 7 of 12

ВeekeeCZ
Consultant
Consultant

This is completely unnecessary. This is intended aliases defined in pgp file. In this case Lisp you get no benefit.

 

https://www.youtube.com/watch?v=6hVmK2gqaQ8

 

However better coding to call AutoCAD origin commands is this:

 

;;Isolate Selected Layer
(defun C:LIO () (command "_.LAYISO") (princ))

 

;;Unisolate Layers
(defun C:LO () (command "_.LAYUNISO") (princ))

0 Likes
Message 8 of 12

steve216586
Advisor
Advisor

"This is completely unnecessary. This is intended aliases defined in pgp file. In this case Lisp you get no benefit."

 

Actually these boards are loaded chok full of people who run into problems because of things like this!!!

 

I can easily see in the near future when a user will request help because they cannot turn certain layers ON, even though they are using LAYUNISO. Because that command will not act a second time, even when not using it in a .lisp. A textmessage will appear which reads, "LAYUNISO No layers to restore from LAYISO command."

 

All due to a .lisp which was loaded into the Startup Suite that they were never aware of nor knew of the command prompt to initiate the .lisp action. As a new hire to that company, and with a fair amount of experience, I would never even guess that woudl be the case. Also as a new hire, with a fair amount of experience in which my compensation package was based upon, I would be embarrassed to ask of if such a thing existed.

"No one can make you feel inferior without your consent. "-Eleanor Roosevelt
0 Likes
Message 9 of 12

Jrooker06
Collaborator
Collaborator

Thank you for explaining that for me. It Will help in in future use.

0 Likes
Message 10 of 12

Kent1Cooper
Consultant
Consultant

@steve216586 wrote:

.... 

I can easily see in the near future when a user will request help because they cannot turn certain layers ON, even though they are using LAYUNISO. Because that command will not act a second time, even when not using it in a .lisp. A textmessage will appear which reads, "LAYUNISO No layers to restore from LAYISO command."

....


That's one of the benefits of my routines [links in Post 4], and in fact one of the reasons I made them -- they nest to as many levels deep as you care to go [see remarks at the first link, and in the top of the files].

Kent Cooper, AIA
0 Likes
Message 11 of 12

Jrooker06
Collaborator
Collaborator

I like these lisp that you created. But do I really need the top part that explains everything or can i delete it. I a, all for leaving the ;; Kent Cooper, August 2011 on there. but i want to cut out the rest of the filler if i could.

0 Likes
Message 12 of 12

Kent1Cooper
Consultant
Consultant

@Jrooker06 wrote:

I like these lisp that you created. But do I really need the top part that explains everything or can i delete it. I a, all for leaving the ;; Kent Cooper, August 2011 on there. but i want to cut out the rest of the filler if i could.


You can remove any line that begins with a semicolon, and anything on other lines from a semicolon rightward -- they're all just commentary.

Kent Cooper, AIA
0 Likes