Jump to content
Silvercloak

Fixing Autocad's Layer Dropdown

Recommended Posts

Silvercloak

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

Share this post


Link to post
Share on other sites
dlanorh

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

Share this post


Link to post
Share on other sites
Stefan BMR
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

Share this post


Link to post
Share on other sites
dlanorh
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

Share this post


Link to post
Share on other sites
Silvercloak
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!

Share this post


Link to post
Share on other sites
Aftertouch


(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"))
            )
        )
    )

Share this post


Link to post
Share on other sites
Roy_043

@Aftertouch

Shouldn't "BLOCK" be "LAYER"?

Edited by Roy_043

Share this post


Link to post
Share on other sites
Aftertouch

@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

Share this post


Link to post
Share on other sites
Silvercloak
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

Share this post


Link to post
Share on other sites
Roy_043
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.

Share this post


Link to post
Share on other sites
dlanorh

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.

 

 

Share this post


Link to post
Share on other sites
Silvercloak

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

Share this post


Link to post
Share on other sites
Aftertouch


(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

Share this post


Link to post
Share on other sites
Silvercloak

AWESOME!  Thanks so much!

Share this post


Link to post
Share on other sites
jonathann3891
(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" "")
  )

 

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...