guran Posted April 29, 2013 Posted April 29, 2013 In Layer properties manager Filters there is an option to Invert filter. Does anyone know if it is possible to toggle this on and off from a lisp. Quote
ReMark Posted April 29, 2013 Posted April 29, 2013 Take a look at this. Maybe it will give you some ideas. http://www.cadtutor.net/forum/showthread.php?40103-Turn-layers-in-filters-on-off-with-button Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 No, I am afraid there was nothing about Invert filter to find there. Quote
ReMark Posted April 29, 2013 Posted April 29, 2013 You want to invert the layer filter not turn it on/off? Can you explain the difference to me? Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 What I want to do is to make a toogle to filter the layers of xrefs on and off Quote
ReMark Posted April 29, 2013 Posted April 29, 2013 Now it's of xrefs. OK. So why wouldn't the lisp routine by Alanjt work? Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 Yuo see, all I want is to make a toggle key. You press it and all the xref layers disappear, you press it again and the xref layers come back and all the other layers disappear. Quote
Lee Mac Posted April 29, 2013 Posted April 29, 2013 @ReMark: I believe the OP is looking to programmatically control the 'Invert filter' toggle within the Layer Manager: Although layer filters can be manipulated programmatically using the undocumented and invisible 'filter' option of the -LAYER command, to my knowledge, it is not possible to alter this toggle using AutoLISP. A workaround (still using Layer Filters) might be to create two complementary layer filters (i.e. one displaying only XRef layers, another displaying everything except XRef layers) and then create a program to alternately set each layer filter as current. Of course, there are many other possible solutions using AutoLISP & Visual LISP if you didn't need want to use layer filters, by manipulating the layers collection directly. Quote
ReMark Posted April 29, 2013 Posted April 29, 2013 Maybe this macro will work? http://cadtips.cadalyst.com/dwg/x-x Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 To bad it is not possible, you see I wanted the toggle to work on all drawings, old, new and external, without having to create any layer filter first. Quote
Tharwat Posted April 29, 2013 Posted April 29, 2013 If you just want to toggle on and off the Xref layers ONLY and nothing is related to filters , I wrote the code (lisp and not macro ) and ready to post if you are interested Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 Thank you Tharwat. Yes, I am interested. Quote
Tharwat Posted April 29, 2013 Posted April 29, 2013 Thank you Tharwat. Yes, I am interested. Check this out . (defun c:Xref-on-off (/ on_off l nm layers v e) ;;--- Tharwat 29. 04. 2013 ---;; ;; turn on / off xref layers ;; (defun on_off (code ent) (entmod (subst (cons 62 code) (assoc 62 ent) ent)) ) (while (setq l (tblnext "LAYER" (not l))) (if (vl-string-search "|" (setq nm (cdr (assoc 2 l)))) (setq layers (cons nm layers)) ) ) (foreach layer layers (if (minusp (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" layer)))) ) ) ) (on_off (abs v) e) (on_off (- v) e) ) ) (princ) ) (vl-load-com) Quote
Lee Mac Posted April 29, 2013 Posted April 29, 2013 Or simply: (defun c:xonoff ( / col def enx ) (while (setq def (tblnext "LAYER" (null def))) (if (wcmatch (cdr (assoc 2 def)) "*|*") (progn (setq enx (entget (tblobjname "LAYER" (cdr (assoc 2 def)))) col (assoc 62 enx) ) (entmod (subst (cons 62 (- (cdr col))) col enx)) ) ) ) (princ) ) Quote
guran Posted April 29, 2013 Author Posted April 29, 2013 Thank you all for trying! I only wanted to be able to turn the Invert filter option in the Layer properties manager off and on, not the layers them selves, but it doesn't seem to be possible. Quote
nod684 Posted April 30, 2013 Posted April 30, 2013 this will be usefull! thanks Tharwat and Leemac! Quote
Tharwat Posted April 30, 2013 Posted April 30, 2013 this will be usefull! thanks Tharwat Happy to hear that Quote
pBe Posted April 30, 2013 Posted April 30, 2013 Or simply: (entmod (subst (cons 62[b][color="#8b0000"] (- (cdr col)[/color][/b])) col enx)) Clever Quote
alanjt Posted April 30, 2013 Posted April 30, 2013 VLISP alternative. I prefer this method, only because I've noticed that, if in drawings with a few hundred layers, you can vlax-for through the layers faster than tblnext. At least, it's appeared that way in my experience. (defun c:XT (/) (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (wcmatch (vla-get-name layer) "*|*") (vlax-put layer 'layeron (~ (vlax-get layer 'layeron))) ) ) (princ) ) (vl-load-com) (princ) However, thinking about what you are really wanting, you can't really say the xref is on or off, you can only check if an xref layer or group of are on/off - giving the posted toggle routines, including my own. Now, you could just unload the xrefs, but that's time consuming. The other, simpler option would be just to have two commands: one to turn all xref layers on and one to turn them all off. I keep these in my startup of misc macros, etc, and are useful from time-to-time. (defun c:XN (/) ;; turn on all xref layers (vlax-for layer (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) (if (wcmatch (vla-get-name layer) "*|*") (vlax-put layer 'layeron 1) ) ) (princ) ) (defun c:XF (/) ;; turn off all xref layers (vlax-for layer (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) (if (wcmatch (vla-get-name layer) "*|*") (vlax-put layer 'layeron 0) ) ) (princ) ) 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.