TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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.
-
Interesting
Let me go look up something of Mark's
-
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
-
I think this is the filter you want
[M][~*|*]*
Anything starting with 'M' followed by anything except containing '|'
-
well that doesn't work but this will.
(setq ss (ssget '((8 . "M*") (8 . "~*|*"))))
-
Cab,
It did'nt work. Thank you for trying.
-
That should work to create a selection set.
What exactly are you trying to do with the layer names?
-
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.
-
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)
-
Sweeeeeettttt :-)
-
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!!!
-
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
-
Krushert,
Me again. From the coding examples, I'm able to create "~M*".
But not the second line "*|*". Do you know how?
-
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*,*|*")
-
Note the the comma is an implied OR.
-
Krushert,
Me again. From the coding examples, I'm able to create "~M*".
But not the second line "*|*". Do you know how?
(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)
)
-
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.
-
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!
-
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. :(
-
MP,
Thanks for checking.
-
You're most welcome ETLC.
-
couldn't you use the NOT?
(ssget '((-4 . "<not")(8 . "*|*")(-4 . "not>"))))