Author Topic: Z coordinate ssget filter LISP?  (Read 6340 times)

0 Members and 1 Guest are viewing this topic.

sparky

  • Guest
Z coordinate ssget filter LISP?
« 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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Z coordinate ssget filter LISP?
« Reply #1 on: May 03, 2004, 05:05:15 PM »
are you trying to filter for anything selected? i.e. lines circles, plines, etc..
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Z coordinate ssget filter LISP?
« Reply #2 on: May 03, 2004, 05:14:53 PM »
how about filtering the selection set ?
Code: [Select]

(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))
    )
  )
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
Re: Z coordinate ssget filter LISP?
« Reply #3 on: May 03, 2004, 06:09:10 PM »
Quote from: sparky
.. 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))))

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Z coordinate ssget filter LISP?
« Reply #4 on: May 03, 2004, 06:54:32 PM »
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
TheSwamp.org  (serving the CAD community since 2003)

sparky

  • Guest
....I can see (because I've just tried it)
« Reply #5 on: May 04, 2004, 03:03:40 AM »
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:

SMadsen

  • Guest
Z coordinate ssget filter LISP?
« Reply #6 on: May 04, 2004, 06:30:48 AM »
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.

sparky

  • Guest
this is something like I used...
« Reply #7 on: May 04, 2004, 06:30:17 PM »
(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.

SMadsen

  • Guest
Z coordinate ssget filter LISP?
« Reply #8 on: May 05, 2004, 03:22:04 AM »
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*")

sparky

  • Guest
those filters...hmmmm
« Reply #9 on: May 05, 2004, 05:09:11 AM »
I didn't know...thanks for the tip!!