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

Layer Isolate and Unisolate -- On/Off condition only

9 REPLIES 9
Reply
Message 1 of 10
Kent1Cooper
29479 Views, 9 Replies

Layer Isolate and Unisolate -- On/Off condition only

Inspired by a recent thread started by claycarr [not-very-helpfully titled "need help with existing code", but it was about isolating Layers and the shortcomings of LAYISO/LAYUNISO]:

 

If you ever use LAYISO [‘Layer Isolate’ in the Layer subsection of Express Tools] to isolate some Layer(s) and turn off the rest, and LAYUNISO to turn back on the ones that were turned off, you may have noticed some shortcomings.  [These apply back in my 2004; some may have been fixed in later versions.  I expect 1. and 2. are, and 3. may be, somehow related to using Layer States, but I’m not sure.  I tried with both conditions for On and Color in the LayerState settings, but it made no difference.]  But if you haven’t, here they are:

  1.  If, while in the layer-isolated condition, you change something about a Layer like its color or linetype, when you later use LAYUNISO, those qualities revert back to what they were when you used LAYISO;

  2.  If, while in the layer-isolated condition, you manually turn off some additional Layers, LAYUNISO does not leave them that way; it does not turn back on only those that LAYISO turned off, but all those that were on at the time LAYISO was used.

  3.  If you use LAYISO once, and then decide you want still fewer Layers on, and use it again, you can use LAYUNISO only to step back from the latest isolation—it won’t go further to turn back on Layers that were turned off by earlier LAYISO commands.

 

But NOT ANY MORE.  To isolate Layers, affecting only their on-off condition, and turn back on the ones that were turned off, without reversing anything like changes in colors or linetypes of Layers that may have happened in between, and to as many levels deep as you care to go, there are two commands in the attached LayerIsolateOnOff.lsp:

Type [or put into a toolbar button or something] LIO [which stands for Layer Isolate – On/Off only] to isolate the Layers of objects you will be asked to select; and

Type [or otherwise] LUO [which stands for Layer Unisolate – On/Off only] to turn back on those that were turned off by using LIO.

You can “stack” them multiple levels deep, and each LUO will turn back on those Layers that were turned off by the corresponding LIO (and only those Layers); do LUO repeatedly to turn back on successive sets of Layers in reverse order of the LIO series.

 

Like LAYISO/LAYUNISO:

  1.  LIO reports how many Layers it has isolated (kept on).

  2.  LIO changes the current Layer to one that’s still on, if you didn’t select anything on the Layer that was current at the time.  [The routine in the other thread goes ahead and turns off the current Layer, because the code they started with did, but I decided I prefer to change it.]

  3.  LIO tells you the name of the current Layer, but only if it has had to change it [see 2.]. (LAYISO tells you the current Layer even if it didn’t change it).

  4.  LUO turns back on Layers even if they have been renamed since the corresponding LIO.

  5.  LUO makes current again the Layer that was current at the time of the corresponding LIO, even if it’s been renamed since [provided it hasn’t been purged].

 

Beyond what LAYISO/LAYUNISO tell you, they also report more about what they’ve done:

  1.  LIO tells you not only how many Layers it isolated (kept on), but how many it turned off.

  2.  LAYUNISO doesn’t report anything at all, but LUO tells you:

    a.  how many Layers it turned back on;

    b.  how many Layers no longer exist and therefore were not turned back on;

    c.  if the Layer that was current at the time of LIO was turned off, and another made current, it tells you that Layer has been made current again.

    d.  if that Layer has been purged, it reports that it therefore hasn't been made current again.

Kent Cooper, AIA
9 REPLIES 9
Message 2 of 10

I always got in the habit of using LAYERP instead of LAYUNISO.

Message 3 of 10


@hidden_intuition wrote:

I always got in the habit of using LAYERP instead of LAYUNISO.


Yes, that lets you take LAYISO to multiple levels of depth, which LAYUNISO won't back you out of.  But it has the same disadvantage the other thread wanted to get around -- if you change something like the color or linetype of a Layer in between, it reverses that change on the way back to turning back on the Layers that were turned off.  LIO/LUO have no effect on anything about Layers except for their On/Off condition, no matter what else may have been done to them in the meantime.

Kent Cooper, AIA
Message 4 of 10
Anonymous
in reply to: Kent1Cooper

Nice concept Kent.  I will have to try it when I get a chance.

 

No disrespect to you Kent.  But whatever happended to using the right tool to do the job at hand?  I use the layer iso for what it is intended for and when I want to change the layer properties I use the layer command.  I do find writing lisp programs a great help in easing the work load but I find some requests here that I want it to do this or that is a little disturbing.  Sometimes I feel these requests are out of pure laziness in doing things the right way.  Then they are complaining that AutoCAD crashes a lot.  At my last job we were interviewing an applicant and when we put them in front of a computer and gave them a CAD test, they couldn't do it because they were so used to lisp programs and the set up at their place of work.  I know this falls on the individuals work ethic and what they are willing and what they want to learn.  I know maybe I am just ranting here but whatever happened to learning your craft.  I worked on learing what the software can and can not do and adjust accordingly.  And writing a lisp program for special needs.

Message 5 of 10
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....  But whatever happended to using the right tool to do the job at hand?  I use the layer iso for what it is intended for and when I want to change the layer properties I use the layer command.  ....


I agree, when the right tool does the job right, and I've often steered people to a command or option they may not have known about, if it can eliminate the need to write a routine.

 

This whole thing came about because of what claycarr [the OP on that other thread] and I consider a real flaw in what ought to be "the right tool to do the job."  Do just what you describe in that order -- use LAYISO for its purpose, and then use the Layer command [or Layer Manager] to change some properties like colors or linetypes, whether of Layers that are still on or of some that are turned off.  Then use LAYUNISO, which ought to be the right tool for the job of just turning back on the Layers you turned off with LAYISO.  Unless it's been fixed in newer versions than mine, you'll lose the changes in properties that you did with Layer or the Layer Manager.  [Interestingly, you don't lose, for instance, any new Layer(s) you may have made, nor get back any Layers you may have purged.]

 

I think it's fair to expect that, because of both their names and their descriptions in Express Tools Help, LAYISO and LAYUNISO would simply turn Layers off and back on.  But they don't work that way [or maybe I should say only that LAYUNISO doesn't work that way; LAYISO seems to do what its description says] -- hence the routine.

Kent Cooper, AIA
Message 6 of 10
Anonymous
in reply to: Kent1Cooper

I do get the jist of your program, I have followed clay's post and your responces.  I realize nobody's perfect, I included, I make mistakes just like everyone else.  Yes I sometimes cancel a command half way thru it or select something wrong.  I just undo a few steps and go forward being a little more careful.  I don't write a program for my mistakes, because I have what I call fat-finger syndrome and my typing is horrible.  Oh well, thanks for the program and your efforts in this forum.

Message 7 of 10
skintsubby
in reply to: Kent1Cooper


@Kent1Cooper wrote:

   Unless it's been fixed in newer versions than mine,


Kent

 

It works as you would expect it to in AutoCAD Map 2012.

 

I.e. LAYUNISO doesn't revert any changes you make, it just brings back the previous layer state.

 

Mark

Message 8 of 10
ВeekeeCZ
in reply to: skintsubby

Hello, I found this routine and its really cool... - thx Kent 🙂 - but I miss fading options providing by lock/unlock functionality. So I decided to accommodate this routine on my own. Job almost done, its lockeng/unlocking quite fine, but still struggling with fading (LAYLOCKFADECTL). The problem is Unisolation.
Run LIL and then LUO... it does its job, and it looks just fine. But if I do REGEN, fades all unlocked layers again even if they are not locked anymore. Please help, how to make unfading permanent... This variable is quite misterious to me, cant figure how it works. Thaks a lot.

Message 9 of 10
Kent1Cooper
in reply to: ВeekeeCZ


@ВeekeeCZ wrote:

.... I miss fading options providing by lock/unlock functionality. So I decided to accommodate this routine on my own. Job almost done, its lockeng/unlocking quite fine, but still struggling with fading (LAYLOCKFADECTL). The problem is Unisolation.
Run LIL and then LUO... it does its job, and it looks just fine. But if I do REGEN, fades all unlocked layers again even if they are not locked anymore. ....


[Here, I have an older version that doesn't have locked-Layer fading.  I'll try experimenting when I'm next where I have access to a newer version.]

Kent Cooper, AIA
Message 10 of 10
ВeekeeCZ
in reply to: Kent1Cooper

Thanks Kent. 🙂

I probably figured the way how to fix it... Its not exactly clean, because I fixed the symptom, not the cause of the problem.

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

Post to forums  

Autodesk Design & Make Report

”Boost