Jump to content

Fixing Autocad's Layer Dropdown


Recommended Posts

Posted

Hi all,

 

   This has been driving me ape for years.  I'll open a drawing, and get working in it.  Realize I need to change layers, so I'll click on the layer dropdown only to discover it's locked into an xref.  I'll have to open the entire layer manager dialogue JUST to switch to non-xref filter.  Seriously, why are xrefs even showing in the drop down?  You can't draw on those layers or do anything with it.  Stupid programming design.   Anyways, ranting aside, I've tried to write a scripted button to switch the filter using the -Layer command but once I get to setting the filter it doesn't really accept "All non-xref layers" as a filter choice.   Leaving me going back to opening the layer manager dialogue box just to change the frigging filter so I can use the dropdown.

 

   Does anyone know how to make a working script for this or is there some kind of fix?

 

Silvercloak

Posted

Does (command "-Layer" "Filter" "Set" "All" "") work?

Posted
20 hours ago, Silvercloak said:

I've tried to write a scripted button to switch the filter using the -Layer command but once I get to setting the filter it doesn't really accept "All non-xref layers" as a filter choice.

Filter name is case-sensitive.

Try dlanorh's suggestion with the correct filter name: (command "-Layer" "Filter" "Set" "All non-Xref Layers" "") 

  • Like 1
Posted
7 hours ago, Stefan BMR said:

Filter name is case-sensitive.

Try dlanorh's suggestion with the correct filter name: (command "-Layer" "Filter" "Set" "All non-Xref Layers" "") 

 

I didn't know about the filter case sensitivity. Thanks Stefan

Posted
On 9/7/2019 at 6:17 AM, Stefan BMR said:

Filter name is case-sensitive.

Try dlanorh's suggestion with the correct filter name: (command "-Layer" "Filter" "Set" "All non-Xref Layers" "") 

 

I tried that idea directly in a toolbar button on my screen.  Didn't work - I'll try it in a lisp later and see how that goes.  Thanks!

Posted


(setq item (tblnext "BLOCK" T))
    (while (/= item nil)
        (if (wcmatch (cdr (assoc 2 item)) "*[|]*")
            (progn
                (setvar "CMDECHO" 0)
                (command "-Layer" "Filter" "Set" "All non-Xref Layers" "")
                (setvar "CMDECHO" 1)
                (setq item nil)
            )
            (progn
                (setq item (tblnext "BLOCK"))
            )
        )
    )

Posted (edited)

@Roy_043

No it shouldnt, the 'All non-Xref Layers' filter is only present when there are XREF's in the DWG.

XREF's are in the DWG as a BLOCK, with a '|' in the name.

 

So it checks if there are XREF's present. If so, the filter is available.

Edited by Aftertouch
Posted (edited)
10 hours ago, Aftertouch said:

 


(setq item (tblnext "BLOCK" T))
    (while (/= item nil)
        (if (wcmatch (cdr (assoc 2 item)) "*[|]*")
            (progn
                (setvar "CMDECHO" 0)
                (command "-Layer" "Filter" "Set" "All non-Xref Layers" "")
                (setvar "CMDECHO" 1)
                (setq item nil)
            )
            (progn
                (setq item (tblnext "BLOCK"))
            )
        )
    )

I made a lisp using this, if I add a (defun c:NOX

to it I get;


; warning: redefinition of built-in symbol: SETQ
; warning: redefinition of built-in symbol: SETQ
; error: bad element in arguments list: (TBLNEXT "BLOCK" T)

If I use your lisp without adding anything to it, I get;

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

Silvercloak

 

Edited by Silvercloak
Posted
3 hours ago, Aftertouch said:

@Roy_043

No it shouldnt, the 'All non-Xref Layers' filter is only present when there are XREF's in the DWG.

XREF's are in the DWG as a BLOCK, with a '|' in the name.

 

So it checks if there are XREF's present. If so, the filter is available.

Are you sure? In BricsCAD only blocks nested in xrefs have this name pattern. The xrefs themselves don't.

Posted

Something is wrong somewhere

 

This error will only occur if there are command calls inside an error routine

 

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

 

Therefore the lisp is erroring, and in my test, unless things have changed since my version (2012), inserting a drawing as an xref does not create the "All non-Xref Layers" filter, rather and "Xref" filter. This should be the first port of call.

 

 

Posted

I'm using 2016.

 

Drawing without Xrefs

image.png.86c55bd797ed7fa0e20cb59d9736c44c.png

 

Drawing WITH Xrefs

 

image.png.c45531b19f5bfebe55825266844f2c3f.png

 

 

This is how I tried to modify it to run everytime I entered in NOX.

(defun c:NOX
(setq item (tblnext "BLOCK" T))
    (while (/= item nil)
        (if (wcmatch (cdr (assoc 2 item)) "*[|]*")
            (progn
                (setvar "CMDECHO" 0)
                (command "-Layer" "Filter" "Set" "All non-Xref Layers" "")
                (setvar "CMDECHO" 1)
                (setq item nil)
            )
            (progn
                (setq item (tblnext "BLOCK"))
            )
        )
    )
  )

 

Silvercloak

Posted


(defun c:NOX ( / item )
(setq item (tblnext "BLOCK" T))
    (while (/= item nil)
        (if (wcmatch (cdr (assoc 2 item)) "*[|]*")
            (progn
                (setvar "CMDECHO" 0)
                (command "-Layer" "Filter" "Set" "All non-Xref Layers" "")
                (setvar "CMDECHO" 1)
                (setq item nil)
            )
            (progn
                (setq item (tblnext "BLOCK"))
            )
        )
    )
(princ)
)

(princ)

  • Thanks 2
Posted
(defun c:nxl ( / xdict dict xrecname )

    (setq xdict
        (vlax-vla-object->ename
            (vla-getextensiondictionary 
                (vla-get-layers 
                    (vla-get-activedocument (vlax-get-acad-object))
                )
            )
        )    
    )
    
    (setq dict
        (if (setq dict (dictsearch xdict "ACAD_LAYERFILTERS"))
            (cdr (assoc -1 dict))
            (dictadd xdict "ACAD_LAYERFILTERS"
                (entmakex
                   '(
                        (0 . "dictionary")
                        (100 . "AcDbDictionary")
                        (280 . 0)
                        (281 . 1)
                    )
                )
            )
        )
    )
    
    (princ
        (if (dictsearch dict (setq xrecname "tempNoXrefLayers"))
            (strcat
                "Layer filter named <"
                xrecname
                "> already exists."
            )
            (if
                (dictadd dict xrecname
                    (entmakex
                        (append
                           '(
                                (0 . "xrecord")
                                (100 . "AcDbXrecord")
                                (280 . 1)
                            )    
                            (list (cons 1 xrecname))
                           '(
                                (1 . "~*|*")
                                (1 . "*")
                                (1 . "*")
                                (70 . 0)
                                (1 . "*")
                                (1 . "*")
                                (-3          
                                    (   "ACAD"
                                        (1000 . "( NAME== \"~*|*\" )")
                                    )         
                                )
                            )    
                        )
                    )
                )
                (strcat
                    "Created layer filter named <"
                    xrecname
                    ">."
                )
                
            )    
        )    
    )    
    
    (princ)
  (command "-layer" "filter" "rename" "tempNoXrefLayers" "No_Xref-Layers" "set" "No_Xref-Layers" "")
  )

 

  • 2 years later...
Posted (edited)
On 07/09/2019 at 02:53, Silvercloak said:

Hi all,

 

   This has been driving me ape for years.  I'll open a drawing, and get working in it.  Realize I need to change layers, so I'll click on the layer dropdown only to discover it's locked into an xref.  I'll have to open the entire layer manager dialogue JUST to switch to non-xref filter.  Seriously, why are xrefs even showing in the drop down?  You can't draw on those layers or do anything with it.  Stupid programming design.   Anyways, ranting aside, I've tried to write a scripted button to switch the filter using the -Layer command but once I get to setting the filter it doesn't really accept "All non-xref layers" as a filter choice.   Leaving me going back to opening the layer manager dialogue box just to change the frigging filter so I can use the dropdown.

 

   Does anyone know how to make a working script for this or is there some kind of fix?

 

Silvercloak

I could not agree more. This has been driving me crazy for years too.  So stupid to even list xref layers in this drop down. Thanks to Aftertouch's routine, I was able to add the routine to a toolbar button and then create a clone of the standard layers toolbar and now I have the fix sitting right next to the layer drop down so whenever this problem comes up, which is all the friggin time, there is a quick fix sitting right next to it. We should not need to be doing these work arounds however. Autodesk should be using our huge licence fees to fix these problems that are just downright annoying to users.

 

2022-05-03 12_53_38-Window.png

Edited by Jim Vtak

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...