LISP to switch Layer Manager to "Local Layer" filter

LISP to switch Layer Manager to "Local Layer" filter

barry2104
Collaborator Collaborator
4,285 Views
19 Replies
Message 1 of 20

LISP to switch Layer Manager to "Local Layer" filter

barry2104
Collaborator
Collaborator

I already have a Lisp to create a local layer filter. As I'm working in Germany, this Layer-Filter is called "Lokale-Layer".

 

When I open layer Manager to find out info about a layer within an Xref, I often forget to Switch back to my "local layer" filter. Then when I'm CADding around and select a line to Change its properties, or specifically its Layer Name, I can then only see the layers from the Xref which I had clicked on in Layer Manager from the drop-down box (see screenshot below)

I then have to unselect my selection (ESC), go back into layer Manager, click on "Lokale-Layer" filter and then relect my elements to Change their layer Name.

 

I'm looking for a Lisp with a command e.g. "LLL" which Switches me (or rather my Layer manager) back to my local layer filter, so that I can fast-track the solution.

Or better yet, a way (Setting that i don't know of perhaps?) to always Default back to a selected / local layer filter to avoid the Problem all together, since I never want to see an Xref layer list in the drop-down box in the pic below. That seems a reach for me though... perhaps a Suggestion to Autodesk for future Versions?

 

Unbenannt.jpg

Running AutoCAD Architecture 2020, in German
0 Likes
Accepted solutions (1)
4,286 Views
19 Replies
Replies (19)
Message 2 of 20

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:LLL ()
  (command "_-layer" "_filter" "_S" "Lokale-Layer" "_X" "")
  (princ)
)

 

You may add this command: (c:lll) into acaddoc.lsp, then it will load on start of each drawing, see HERE

 

Message 3 of 20

barry2104
Collaborator
Collaborator

thanks for the quick reply, but it doesn't seem to quite work...

the drop-down box is now empty rather than showing the list from the "Lokale-Layer" Layerfilter

Unbenannt.jpg

Running AutoCAD Architecture 2020, in German
0 Likes
Message 4 of 20

ВeekeeCZ
Consultant
Consultant
Can't think of any reason why it would work that way. I'm using this for years.
Would you post your dwg? You an erase all the objects, just leave layer and layer filters.
BTW what version of autocad do you have?
0 Likes
Message 5 of 20

barry2104
Collaborator
Collaborator

using AutoCAD 2016

see attachment

Running AutoCAD Architecture 2020, in German
0 Likes
Message 6 of 20

ВeekeeCZ
Consultant
Consultant

Sorry, I may not be able to help you.

I'm even unable to set your filter current by ANY means! Not by the Layer Manager, nor by Command Line. Using Autocad 2016 C3D.

 

Try the code below. You may try play with the code, try run it twice...

 

(defun c:lll ()
  (command "_.LAYER" "_FILTER" "_D" "Lokale-Layer" "")
  (command "_.LAYER" "_FILTER"	"_N" "_P" "All" "NAME==\"~*|*\"" "Lokale-Layer") (if (> (getvar 'CMDACTIVE) 0) (command ""))
  (command "_.LAYER" "_FILTER" "_S" "Lokale-Layer" "_X" "")
  (princ))

Lines:

1) delete current local filter

2) recreate new one

3) sets it current

 

BTW Since you're using you can add LayerFilterCombo into Ribbon (maybe instead of LayerStateCombo) and control and change filters directly from Ribbon. See attached printscreen.

Message 7 of 20

barry2104
Collaborator
Collaborator

I'm not familiar with LayerFilterCombo - what is it and how do i add it to my ribbon?

after reloading the Lisp with your amended text, i get the following pop-up window...

 

Unbenannt.JPG

after simply closing it, the Lisp runs, but again to no avail. This time I don't see any Change to the drop-down layer list (still only showing the Xref-Layers in the drop down list, along with the current layer of course)

 

Running AutoCAD Architecture 2020, in German
0 Likes
Message 8 of 20

ВeekeeCZ
Consultant
Consultant

HERE is the screencast showing how to add it into the UI (I haven't actually done it, just show how...)

 

Try this...

(defun c:lll ()
  (command "_.LAYER" "_FILTER" "_Delete" "Lokale-Layer" "")
  (command "_.LAYER" "_FILTER"	"_New" "_Property" "_All" "NAME==\"~*|*\"" "Lokale-Layer") (if (> (getvar 'CMDACTIVE) 0) (command ""))
  (command "_.LAYER" "_FILTER" "_Set" "Lokale-Layer" "_X" "")
  (princ))

...see your command line, maybe the "All" is translated so it needs to be "_All" or german "Alle" ??? Check it yourself.

 

If it does not work, post the command line listing... But try it to fix yourself first.

0 Likes
Message 9 of 20

barry2104
Collaborator
Collaborator

Here's the command line Output:


Befehl: LLL Unbekannter Befehl "SET". Drücken Sie F1-Taste für Hilfe.
Unbekannter Befehl "LOKALE-LAYER". Drücken Sie F1-Taste für Hilfe.
Unbekannter Befehl "X". Drücken Sie F1-Taste für Hilfe.
Unbekannter Befehl "LLL". Drücken Sie F1-Taste für Hilfe.

 

Looks like i Need to translate the commands "X" and "SET" to be comprehensible in my german System, since the "_" prefix doesn't seem to help there... Can you describe their functions in english for me? I don't personally know how Lisp script language works...

 

unfortunately that screencast doesn't quite apply to me with a german setup, as I don't know the translations into german for the selected Tabs (or rather, can't find the applicable file to drag and drop within the CUI Dialogue)

Running AutoCAD Architecture 2020, in German
0 Likes
Message 10 of 20

ВeekeeCZ
Consultant
Consultant

Try to add a dash "_.-LAYER"

 

Set is for Set the current.

X is for eXit.

 

But decisive is the first error.

 

See the screenshot. Find it by your current Profil...

0 Likes
Message 11 of 20

barry2104
Collaborator
Collaborator

no dice unfortunately, same Problem as without the - infront of Layer

oh well

Running AutoCAD Architecture 2020, in German
0 Likes
Message 12 of 20

Edwin.Saez
Advisor
Advisor

@barry2104,

 

This is what you need?

 

http://autode.sk/2swaGdn

 

 

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

Message 13 of 20

barry2104
Collaborator
Collaborator

that Looks great, but how do I get that to work? no instructions in the Video link... I don't know how to get those shortcut-Icons on to my Profile and the command "FILTRO" must be an add-on/Lisp...

Running AutoCAD Architecture 2020, in German
0 Likes
Message 14 of 20

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

look to that screenshot and the name of the layerfilter (the global one) in German AutoCAD:

 

20170606_104738.png

 

And what is quite unusual, but in that case happens: the global layerfilter in German AutoCAD is called "ALLE" and in that special case that can not be used with the international prefix "underline"+English-name to get it working in other languages. ...what means you can't use "_ALL", you need to use the word "ALLE" in German.

 

Code which works for me, based on the one from @ВeekeeCZ is that:

(defun c:lll ()
  (command "_.LAYER" "_FILTER" "_Delete" "Lokale-Layer" "")
  (command "_.LAYER" "_FILTER"	"_New" "_Property" "ALLE" "NAME==\"~*|*\"" "Lokale-Layer") (if (> (getvar 'CMDACTIVE) 0) (command ""))
  (command "_.LAYER" "_FILTER" "_Set" "Lokale-Layer" "_X" "")
  (princ)
)

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 15 of 20

barry2104
Collaborator
Collaborator

the new code from Alfred works better than previously, but not quite what I'm after.

After typing in LLL the Dropdown list now Shows all layers rather than just the layers that should be visible through the "Lokale-Layer" filter. This means i now still have to scroll through sometimes 1000+ layers to pick the local layer i want to assign an element to. If I only have 10 local layers, and 1000+ xref layers, then this is still not much of a time saver considering the amount of Scrolling i Need to do within the Dropdown list.

I don't know what to tweak in the code to get this Dropdown list to only Show layers found within a customised layer filter ("Lokale-Layer") though!

 

otherwise, can anyone shed more light on post 12 above? That screencast Looks like what I want to achieve, but I don't see any instructions on how to set it up like that.

Running AutoCAD Architecture 2020, in German
0 Likes
Message 16 of 20

ВeekeeCZ
Consultant
Consultant

Alfred, thank you for the update.

 

Would you try (or translate) the code from post #2? Would you confirm that it works in German version?

 

Because this code is basically all we need... and it works for me for years...

 

THX

 

 

@barry2104  Does it make your lokale-layer filter active? You need to post some screenshots or screencast, command line listening... We need to see what really happened otherwise we're unable to help you!!!

BTW The filter Lokale-Layer in your posted example does include 69 layers, not not just 10...

 

OR try this alternative:

(defun c:lll ()
  (command "_.+LAYER" "Lokale-Layer")
  (princ)
)
0 Likes
Message 17 of 20

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> Would you try (or translate) the code from post #2? Would you confirm that it works in German version?

Code does not need a translation, works well in German AutoCAD 2017 too.

(the filter given in the lisp-tool is made active and so the layer combo shows only the filtered layers ... well not with the sample drawing as we don't have XRefs in it, but modified the filter "Lokale Layer" to just show "*-BAUW*" layers, then made layerfilter "ALLE" active, closed layermanager, ran your tool and after that only one layer is listed in the layer combo ==> that's my understanding of how the tool should work)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 18 of 20

barry2104
Collaborator
Collaborator

not sure why this code gave me Problems last week, but upon trying it again today, it works

 

Problem solved!

If anyone has more info about the above screencast from post 12, there could be Bonus Points involved...

Running AutoCAD Architecture 2020, in German
0 Likes
Message 19 of 20

ВeekeeCZ
Consultant
Consultant

Thanks God!

 

I have very similar buttons, as you could see from my screenshot. It wars even better with previously noticed LayerFilterCombo which gives you visual control.

 

You need to make sure that your LLL routine is always loaded - use the StartUp Suite or acaddoc.lsp. 

 

Then you can follow the screencast HERE (my UI is highly customized so you have different tabs and Panels...)

Edit: part of 1'-1'55" I should have cut off - I am just searching for the Icon name. 

 

Good luck.

0 Likes
Message 20 of 20

Edwin.Saez
Advisor
Advisor

With pleasure to help you Here in this video that you can see how I did it.
You need to create 2 new commands, and add the following macros:


- ^ C ^ C-LAYER; _FILTER; SET; All non-Xref Layers ;; (All layers except the xref layers are shown)
- ^ C ^ C-LAYER; _FILTER; SET; Xref ;; (Only the xref layers are shown)

 

filtername.jpg

 

 

 

 

 

 

Create commands, add it to the shortcut bar, to use it always quickly.

 

 

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature


 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

0 Likes