TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: daron on December 03, 2007, 11:46:01 AM

Title: ssget filters
Post by: daron on December 03, 2007, 11:46:01 AM
It's been a while since I messed with these so maybe this is just something little that I'm overlooking, but...

I'm trying to get a selection set and during the getting process NOT allow lwpolylines that are closed. I've tried this:
Code: [Select]
(ssget (list '(-4 . "<NOT")
'(70 . 1)
'(-4 . "NOT>")
)
)
and
Code: [Select]
(ssget (list '(-4 . "<NOT")
                '(-4 . "<AND")
                '(0 . "LWPOLYLINE")
'(70 . 1)
                '(-4 . "AND>")
'(-4 . "NOT>")
)
)
Both ways I get closed plines. What am I missing?
Title: Re: ssget filters
Post by: CAB on December 03, 2007, 12:01:45 PM
Try this one.
Code: [Select]
(ssget '((0 . "LWPOLYLINE")(-4 . "<not")(-4 . "&")(70 . 1)(-4 . "NOT>")))
Title: Re: ssget filters
Post by: T.Willey on December 03, 2007, 12:02:13 PM
Both ways work here.  Maybe the polyline are not really closed.  They could have the same end point and start point, but not be closed.  I think that is what is happening to you.  I drew a rectangle and a three segment polyline, and only the three segment pline was selected.
Title: Re: ssget filters
Post by: daron on December 03, 2007, 12:24:39 PM
Hmm. Tim, I found my problem and you're right, they both work. However, the objects are closed, but according to the help files the lwpolyline dxf flags are this:
Quote
1 = Closed; 128 = Plinegen
So, while this code:
Code: [Select]
(ssget (list '(-4 . "<NOT")
                '(-4 . "<AND")
                '(0 . "LWPOLYLINE")
'(70 . 1)
                '(-4 . "AND>")
'(-4 . "NOT>")
)
)
will find and remove polylines that are closed, it will not find ones that have both flags set, so the code needs to be:
Code: [Select]
(ssget (list '(-4 . "<NOT")
       '(-4 . "<or")
       '(70 . 129)
       '(70 . 1)
       '(-4 . "or>")
       '(-4 . "NOT>")
  )
  )
or something similiar.
Thanks for getting me to dig in a little deeper and for the help. Anyway, the code you posted looks like it will only find plines and as long as they are not closed. I want to allow selection of any object type except closed plines. No biggie though. It's figured out. Thanks again.
Title: Re: ssget filters
Post by: Jeff_M on December 03, 2007, 12:52:16 PM
Daron,
There is a Bitwise operator that can be used in lieu of the OR's......doesn't make much difference code-wise in this case since there are only 2 variations to check for, but for future reference when trying to filter for something else (or, if they add more to the LWPLINE's 70 code) look at using the "&" bitwise  operator.
Code: [Select]
(ssget (list '(-4 . "<NOT")
       '(-4 . "&")
       '(70 . 1)
       '(-4 . "NOT>")
  )
  )
Title: Re: ssget filters
Post by: CAB on December 03, 2007, 12:57:27 PM
As Jeff points out, the example I posted does work with '(70 . 129)
Title: Re: ssget filters
Post by: Jeff_M on December 03, 2007, 01:02:34 PM
As Jeff points out, the example I posted does work with '(70 . 129)
Heh, Now how did I not see your post CAB? Oh I see, you slipped in there between the 2 times I visited this thread. :oops:
Title: Re: ssget filters
Post by: CAB on December 03, 2007, 01:04:53 PM
I'm in stealth mode  8-)
Title: Re: ssget filters
Post by: T.Willey on December 03, 2007, 01:17:45 PM
You're welcome for what I did.

Thanks Jeff and Alan, as I learned something new because of what you guys did.  Time to go home!  :-D
Title: Re: ssget filters
Post by: daron on December 03, 2007, 03:09:21 PM
Sorry. A little confusion. CAB, I read your code post as if T.Willey wrote it. Sorry to not give credit properly. T's comment "Maybe the polyline are not really closed." prompted me to dig a little deeper into the object I was inspecting. even though it was closed, it had the 128 bit set. As for the code, are you and Jeff saying that the & operator is an AND or OR? Also, maybe it's just me, but the html coder in me doesn't like to see code not closed out as would be the case with that bitwise operator. :-D
Title: Re: ssget filters
Post by: CAB on December 03, 2007, 03:28:34 PM
Yes it is a bitwise AND with no CLOSE used in that case.
Here is where I learned about it. :-)
http://www.theswamp.org/index.php?topic=4214.msg50368#msg50368
Title: Re: ssget filters
Post by: ronjonp on December 03, 2007, 03:35:00 PM
Yes it is a bitwise AND with no CLOSE used in that case.
Here is where I learned about it. :-)
http://www.theswamp.org/index.php?topic=4214.msg50368#msg50368


WOW :-o ... that thread has me a little bit embarrassed :oops:
Title: Re: ssget filters
Post by: daron on December 03, 2007, 04:33:57 PM
Aha. That makes sense. Thanks Alan.