Jump to content

Recommended Posts

Posted

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.

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • guran

    7

  • alanjt

    5

  • ReMark

    4

  • Tharwat

    4

Top Posters In This Topic

Posted Images

Posted

No, I am afraid there was nothing about Invert filter to find there.

Posted

You want to invert the layer filter not turn it on/off? Can you explain the difference to me?

Posted

What I want to do is to make a toogle to filter the layers of xrefs on and off

Posted

Now it's of xrefs. OK. So why wouldn't the lisp routine by Alanjt work?

Posted

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.

Posted

@ReMark: I believe the OP is looking to programmatically control the 'Invert filter' toggle within the Layer Manager:

 

invertfilter.png

 

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.

Posted

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.

Posted

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 :)

Posted

Thank you Tharwat. Yes, I am interested.

Posted
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)

Posted

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

Posted

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.

Posted

this will be usefull! thanks Tharwat and Leemac! :)

Posted
Or simply:

               (entmod (subst (cons 62[b][color="#8b0000"] (- (cdr col)[/color][/b])) col enx))

 

Clever :thumbsup:

Posted

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

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