Author Topic: ssget LWPOLYLINE filtering  (Read 1444 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
ssget LWPOLYLINE filtering
« on: February 18, 2017, 11:40:35 AM »
Hi guys,  :-) I got curious about this:
How to construct 3 different ssget filters for LWPOLYLINE that:
  • The first allows only LWpolylines that all of their segments are bulges
  • The second allows only LWpolylines that some of their segments are bulges
  • The third allows only LWpolylines that all of their segments are straight
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: ssget LWPOLYLINE filtering
« Reply #1 on: February 18, 2017, 12:34:25 PM »
- LWPOLYLINES without bulges - with straight segments :
(setq s (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<not") '(-4 . "<>") '(42 . 0.0) '(-4 . "not>"))))
- LWPOLYLINES with bulges - without straight segments :
(setq s (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<not") '(-4 . "=") '(42 . 0.0) '(-4 . "not>"))))
- LWPOLYLINES with some bulges and some straight segments :
(setq s (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<and") '(-4 . "<or") '(-4 . "=") '(42 . 0.0) '(-4 . "or>") '(-4 . "<or") '(-4 . "<>") '(42 . 0.0) '(-4 . "or>") '(-4 . "and>"))))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: ssget LWPOLYLINE filtering
« Reply #2 on: February 18, 2017, 12:46:41 PM »
The last filter can be simplified (AND is implicit in a selection filter list):

Code - Auto/Visual Lisp: [Select]
  1. '((0 . "LWPOLYLINE") (-4 . "=") (42 . 0.0) (-4 . "<>") (42 . 0.0))
Speaking English as a French Frog

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: ssget LWPOLYLINE filtering
« Reply #3 on: February 18, 2017, 01:22:25 PM »
Thanks, Marko!
Now I see that the answer had to do with the "NOT" groupcode, as I've tried this at first (but got different results):
Code - Auto/Visual Lisp: [Select]
  1. (sssetfirst nil ; - LWPOLYLINES that have some straight segments :  
  2.   (ssget (list '(0 . "LWPOLYLINE") '(-4 . "=") '(42 . 0.0)))
  3. )
  4.  
  5. (sssetfirst nil ; - LWPOLYLINES that have some bulges :
  6.   (ssget (list '(0 . "LWPOLYLINE") '(-4 . "!=") '(42 . 0.0)))
  7. )
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: ssget LWPOLYLINE filtering
« Reply #4 on: February 18, 2017, 04:18:00 PM »
Grrr, note that every vertex comes with a bulge, even the last one in open polylines. Usually, this last bulge is 0.0, so you cannot differentiate an open, full bulged polyline from a polyline which has some straight and some bulged segments.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: ssget LWPOLYLINE filtering
« Reply #5 on: February 19, 2017, 05:48:42 AM »
Thanks Stefan,
I didn't notice that an open polyline have segment group codes for every vertex.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg