TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: EagerToLearnCad on December 22, 2008, 01:39:46 PM

Title: Layer filter wildcards
Post by: EagerToLearnCad on December 22, 2008, 01:39:46 PM
Hi,

For layer filters, if I just want the main layers names (excluding xref layer name)
in a drawing I use the wilcard "~*|*".

What woud the wildcard be if I want only layers that begin with letter "M"
(m for mechanical) & excluding all xref layers?....Thanks in advance.
Title: Re: Layer filter wildcards
Post by: Krushert on December 22, 2008, 01:55:23 PM
Interesting
Let me go look up something of Mark's
Title: Re: Layer filter wildcards
Post by: Krushert on December 22, 2008, 02:26:45 PM
This is interesting.  looks like you an only filter for either or the first time.  It seems you can not filter a already filter list. 

Somebody a lot smarter that me might think of a way around this.

In the meantime, you might want to take a look at Mark's Using wildcards to find things (http://www.theswamp.org/index.php?topic=24227.msg292756#msg292756).  Very helpful for me so far.  until now
Title: Re: Layer filter wildcards
Post by: CAB on December 23, 2008, 06:59:02 AM
I think this is the filter you want
[M][~*|*]*
Anything starting with 'M' followed by anything except containing '|'
Title: Re: Layer filter wildcards
Post by: CAB on December 23, 2008, 07:43:21 AM
well that doesn't work but this will.
Code: [Select]
(setq ss (ssget '((8 . "M*") (8 . "~*|*"))))
Title: Re: Layer filter wildcards
Post by: EagerToLearnCad on December 23, 2008, 08:38:43 AM
Cab,

It did'nt work. Thank you for trying.
Title: Re: Layer filter wildcards
Post by: CAB on December 23, 2008, 09:52:19 AM
That should work to create a selection set.
What exactly are you trying to do with the layer names?
Title: Re: Layer filter wildcards
Post by: Krushert on December 23, 2008, 10:01:12 AM
Here is is a routine from MP  (http://www.theswamp.org/index.php?topic=12640.msg154988#msg154988)that I use a lot to create the filter out xrefs layers. 
It is worth sharing both from it value in what it does and the hope of you might be able to mine something from the code.
Title: Re: Layer filter wildcards
Post by: MP on December 23, 2008, 10:15:22 AM
Hi,

For layer filters, if I just want the main layers names (excluding xref layer name)
in a drawing I use the wilcard "~*|*".

What woud the wildcard be if I want only layers that begin with letter "M"
(m for mechanical) & excluding all xref layers?....Thanks in advance.

If you're trying to create a layer filter AND you're not interested in doing it thru code one way you could achieve the above is to use a filter that matches the opposite of what you want and invert it. I don't have a lot of experience creating them manually but I believe you need to create 2 entries for the filter above, one would be ~M* and the other would be *|*.

Inverted it yields "All layers that start with M that are not xref based".

Edit: Added piccy:

       (http://www.theswamp.org/screens/mp/layer_filter.png)
Title: Re: Layer filter wildcards
Post by: Krushert on December 23, 2008, 10:34:04 AM
Sweeeeeettttt  :-)
Title: Re: Layer filter wildcards
Post by: EagerToLearnCad on December 23, 2008, 11:22:29 AM
MP,

Thank you!..By the way, What did you mean  "Edit: Added piccy:"?


Krushert,
Thank you too!..You saved me time. This was the next thing I was going
to research.

Happy Holidays Everyone!!!

Title: Re: Layer filter wildcards
Post by: Krushert on December 23, 2008, 11:25:04 AM
MP,

Thank you!..By the way, What did you mean  "Edit: Added piccy:"?


Krushert,
Thank you too!..You saved me time. This was the next thing I was going
to research.

Happy Holidays Everyone!!!



No problem and Welcome to The Swamp

MP had come back and added the image of the screen shot
Title: Re: Layer filter wildcards
Post by: EagerToLearnCad on December 23, 2008, 12:21:24 PM
Krushert,

Me again. From the coding examples, I'm able to create "~M*".
But not the second  line "*|*". Do you know how?
Title: Re: Layer filter wildcards
Post by: ronjonp on December 23, 2008, 12:38:17 PM
Krushert,

Me again. From the coding examples, I'm able to create "~M*".
But not the second  line "*|*". Do you know how?


Separate the filters with a comma. (1 . "m*,*|*")
Title: Re: Layer filter wildcards
Post by: CAB on December 23, 2008, 12:47:12 PM
Note the the comma is an implied OR.
Title: Re: Layer filter wildcards
Post by: MP on December 23, 2008, 12:48:24 PM
Krushert,

Me again. From the coding examples, I'm able to create "~M*".
But not the second  line "*|*". Do you know how?

Code: [Select]
(defun c:EagerToLearnCAD ( / 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 "EagerToLearnCAD"))
            (strcat
                "Layer filter named <"
                xrecname
                "> already exists."
            )
            (if
                (dictadd dict xrecname
                    (entmakex
                        (append
                           '(
                                (0 . "xrecord")
                                (100 . "AcDbXrecord")
                                (280 . 1)
                            )   
                            (list (cons 1 xrecname))
                           '(
                                (1 . "~M*,*|*")
                                (1 . "*")
                                (1 . "*")
                                (70 . 0)
                                (1 . "*")
                                (1 . "*")
                                (-3         
                                    (
                                        "ACAD"
                                        (1000 . "( NAME== \"~M*\" or NAME== \"*|*\" )")
                                    )
                                )
                            )   
                        )
                    )
                )
                (strcat
                    "Created layer filter named <"
                    xrecname
                    ">."
                )
                "Doh! Something horrible happened: Call mommy."
            )   
        )   
    )   
   
    (princ)
   
)
Title: Re: Layer filter wildcards
Post by: EagerToLearnCad on December 23, 2008, 01:16:04 PM
Thanks guys!

MP,

One last. Do you know how to check/select the "Invert Filter" checkbox with lisp? I would
like to be able to toggle it (check/unchecked) in my small program.
Title: Re: Layer filter wildcards
Post by: mkweaver on January 02, 2009, 02:18:03 PM
Thanks guys!

MP,

One last. Do you know how to check/select the "Invert Filter" checkbox with lisp? I would
like to be able to toggle it (check/unchecked) in my small program.

When you figure out the toggle code, have it email you a penny each time its run, then post the code.  You'll be able to retire!
Title: Re: Layer filter wildcards
Post by: MP on January 02, 2009, 02:24:47 PM
I'm likely wrong but I don't believe it's available to lispers. I've scanned the system variables, environment variables, atoms family, the registry, ini files ad infinitum, no can find. :(
Title: Re: Layer filter wildcards
Post by: EagerToLearnCad on January 02, 2009, 08:17:50 PM
MP,

Thanks for checking.
Title: Re: Layer filter wildcards
Post by: MP on January 03, 2009, 11:50:37 AM
You're most welcome ETLC.
Title: Re: Layer filter wildcards
Post by: alanjt on January 03, 2009, 09:42:16 PM
couldn't you use the NOT?

Code: [Select]
(ssget '((-4 . "<not")(8 . "*|*")(-4 . "not>"))))