Silvercloak Posted September 6, 2019 Posted September 6, 2019 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 Quote
dlanorh Posted September 6, 2019 Posted September 6, 2019 Does (command "-Layer" "Filter" "Set" "All" "") work? Quote
Stefan BMR Posted September 7, 2019 Posted September 7, 2019 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" "") 1 Quote
dlanorh Posted September 7, 2019 Posted September 7, 2019 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 Quote
Silvercloak Posted September 9, 2019 Author Posted September 9, 2019 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! Quote
Aftertouch Posted September 10, 2019 Posted September 10, 2019 (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")) ) ) ) Quote
Roy_043 Posted September 10, 2019 Posted September 10, 2019 (edited) @Aftertouch Shouldn't "BLOCK" be "LAYER"? Edited September 10, 2019 by Roy_043 Quote
Aftertouch Posted September 10, 2019 Posted September 10, 2019 (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 September 10, 2019 by Aftertouch Quote
Silvercloak Posted September 10, 2019 Author Posted September 10, 2019 (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 September 10, 2019 by Silvercloak Quote
Roy_043 Posted September 10, 2019 Posted September 10, 2019 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. Quote
dlanorh Posted September 10, 2019 Posted September 10, 2019 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. Quote
Silvercloak Posted September 10, 2019 Author Posted September 10, 2019 I'm using 2016. Drawing without Xrefs Drawing WITH Xrefs 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 Quote
Aftertouch Posted September 11, 2019 Posted September 11, 2019 (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) 2 Quote
Silvercloak Posted September 11, 2019 Author Posted September 11, 2019 AWESOME! Thanks so much! Quote
jonathann3891 Posted September 13, 2019 Posted September 13, 2019 (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" "") ) Quote
Jim Vtak Posted May 3, 2022 Posted May 3, 2022 (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. Edited May 3, 2022 by Jim Vtak Quote
Recommended Posts
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.