lisp to isolate layers using wildcards in the name...

lisp to isolate layers using wildcards in the name...

danglar
Advocate Advocate
2,708 Views
7 Replies
Message 1 of 8

lisp to isolate layers using wildcards in the name...

danglar
Advocate
Advocate

I find very useful routine to delete layers using laydel with wildcards in the name here:
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-delete-layers-using-laydel-wi...
my question is:
Is it possible to modify some of these programs in this topic in order to isolate layers in a same way?
I tried to solve this issue but I have a problem: Layiso command used layers picked by user and I don't know how to take these layers names as initial values
Any help will by very appreciated.

0 Likes
Accepted solutions (2)
2,709 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

That's a lot easier, since isolating Layers is just a function of having them On and all other Off, both of which [unlike deleting them] are achievable within the Layer command's regular options:

 

(setq laynames (getstring "\nEnter Layer Name(s) to isolate [wild-cards can be used]: "))

(command "_.layer" "_off" "*" "_yes" "_on" laynames "")

 

Or, if you will always want a group of Layer names with the same beginning, and to wild-card the rest:

 

(setq laybase (getstring "\nEnter start of Layer Names to isolate all that begin that way: "))

(command "_.layer" "_off" "*" "_yes" "_on" (strcat laybase "*") "")

 

You may also want to include something to set the current Layer to one of those that will be on, which makes it a little more complicated but is certainly doable.  Or you may choose to answer "_no" to the question of whether to turn the current Layer off.

 

Kent Cooper, AIA
0 Likes
Message 3 of 8

hmsilva
Mentor
Mentor
Accepted solution

@apelbaum2014 wrote:

I find very useful routine to delete layers using laydel with wildcards in the name here:
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-delete-layers-using-laydel-wi...
my question is:
Is it possible to modify some of these programs in this topic in order to isolate layers in a same way?
I tried to solve this issue but I have a problem: Layiso command used layers picked by user and I don't know how to take these layers names as initial values
Any help will by very appreciated.


Hi Igal,

perhaps something like this:

(defun c:demo ( / laynames ss)
    (if (and (setq laynames (getstring T "\nEnter Layer Name(s) to isolate 'wild-cards can be used': "))
             (setq ss (ssget "_X" (list (cons 8 laynames) (cons 410 (getvar 'CTAB)))))
             )
        (command "_.layiso" ss "")
        (prompt (strcat "\nNo objects found in layers " laynames "... "))
        )
    (princ)
    )

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 4 of 8

danglar
Advocate
Advocate

Thank you for your efforts. Routine working good!
Now i need an "emulation" of LAYUNISO function. After invoking "demo" function for example regular LAYUNISO function can not return previous position...
I think on this step need to involve layerstate-save and layerstate-restore functions..
How can I do it?

0 Likes
Message 5 of 8

hmsilva
Mentor
Mentor

@apelbaum2014 wrote:

Thank you for your efforts. Routine working good!
Now i need an "emulation" of LAYUNISO function. After invoking "demo" function for example regular LAYUNISO function can not return previous position...
I think on this step need to involve layerstate-save and layerstate-restore functions..
How can I do it?


You're welcome!

 

'regular LAYUNISO function can not return previous position...'

???

 

Command: DEMO

Enter Layer Name(s) to isolate 'wild-cards can be used': _*
_.layiso
Current setting: Hide layers, Viewports=Off

Select objects on the layer(s) to be isolated or [Settings]:   1814 found

Select objects on the layer(s) to be isolated or [Settings]:
6 layers have been isolated. Layer _model is current.
Command:
Command: LAYUNISO
Layers isolated by LAYISO command have been restored.

 

LAYUNISO command, will restore the previous layer state...

 

Henrique

EESignature

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@apelbaum2014 wrote:

.... Now i need an "emulation" of LAYUNISO function. ....


If you use a regular-Layer-command approach [such as suggested in Post 2], then the LAYERP command will take you back to the previous condition.

Kent Cooper, AIA
0 Likes
Message 7 of 8

danglar
Advocate
Advocate

Thank you Henrique and Kent!

It was my mistake..

Program working properly without any problems..

0 Likes
Message 8 of 8

hmsilva
Mentor
Mentor

You're welcome!
Glad I could help

Henrique

EESignature

0 Likes