TheSwamp
CAD Forums => CAD General => Topic started by: sparky on May 03, 2004, 03:26:33 PM
-
:shock:
I’m a beginner…so excuse me please?
I’m trying to write an SSGET filter list that, among other things, will filter all entities with a Z-Coordinate greater than 10 (say).
I’ve tried help files and even checked out some “Selection Set” tutorials, but am still blind to the solution.
Can you help! It might save me time.
-
are you trying to filter for anything selected? i.e. lines circles, plines, etc..
-
how about filtering the selection set ?
(setq ss (ssget)
cntr 0
)
(if ss
(repeat (sslength ss)
(setq ent (ssname ss cntr))
(if
(or
(> (last (assoc 10 (entget ent))) 10.0)
(> (last (assoc 11 (entget ent))) 10.0)
)
(setq entlst (cons ent entlst))
)
(setq cntr (1+ cntr))
)
)
-
.. but am still blind to the solution.
I don't blame you. Filtering by coordinates isn't seen all that often but it is built into SSGET.
You need a relational test looking something like this:
(setq sset (ssget "X" '((-4 . "*,*,>=")(10 0.0 0.0 10.0))))
^this will filter all entities with a group 10 point that has Z greater than or equal to 10.0
The relational test for each coordinate is separated by commas in the -4 group and the point is simply given as it appears in the entity list, except each coordinate is a criterium.
If you need to filter more point groups, you need to provide more -4 groups. For example, to filter both group 10 and 11:
(setq sset (ssget "X" '((-4 . "*,*,>=")(10 0.0 0.0 10.0)(-4 . "*,*,>")(11 0.0 0.0 10.0))))
-
this "*,*, is the part I didn't get. I knew you had to use the -4 and '>' but could not figure out how to filter the X and Y. Thanks for the lesson Mr. Madsen, always a pleasure. :D
-
Thanks very much!! :lol: I slept on it last night and woke up as cloudy as ever. But your solution is perfect and I can now incorporate it into any ssget list I ever use.
I forgot to put the accociative code 10 in the point list!!
I'll definetly be back to browse the post and may be even throw in something I'm working on....it's not finished yet!
And of course I've always got questions!
:? :oops:
-
It's only necessary to add as many asterix's as it takes to force the test to a coordinate. E.g. if the test is only concerned about the X coordinate, it would be enough to use only one operator:
(ssget "X" '((-4 . ">")(10 25.0 0.0 0.0)))
To skip the X and look at Y, use an asterix for X:
(ssget "X" '((-4 . "*,>")(10 0.0 25.0 0.0)))
... and so on
The criteria need to be at least a 2D point, though.
-
(defun demo ()
(setq ss (ssget "X" '((-4 . "<or")
(8 . "*OBERIRD-OBJ*")
(8 . "D_VA*")
(-4 . "<AND")
(8 . "*INFORMATION*")
(-4 . "*,*,>")(10 0.0 0.0 0.1)
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(COMMAND "COPY" ss "" "0,0,0" "@-1000,-1000,0")
)
; selects all entities on layers with "...OBERIRDOBJ..." and "D_VA..." in the layer names
; aswell as all entities on layers with "...INFORMATION..." which have a Z coordinate greater than 0.1 !!
; then copys them -1000 in the X-Dir and -1000 in the Y-Dir relative to where they currently are.
Hope something similar will work out for anyone interested.
-
Excellent!
You know it's possible to comma-separate strings in the criteria, right?
(8 . "*OBERIRD-OBJ*")
(8 . "D_VA*")
is equal to
(8 . "*OBERIRD-OBJ*,D_VA*")
-
I didn't know...thanks for the tip!!