Author Topic: How to construct a selection?  (Read 5782 times)

0 Members and 1 Guest are viewing this topic.

taner

  • Guest
How to construct a selection?
« on: August 27, 2007, 05:56:02 AM »
There is a closed entity such as circle/ellipse/*polyline,How to construct a selection that all member of the selection are in the closed entity,except intersection point on the closed entity?

Just like the attached drawing,the elements of the selection are in the red circle,incloud these curves intersect with the red circle on the start or end point,but the other parts are completely in the circle. The circle may be any type curves.In this drawing,only the red circle and the yellow curves are not in the selection.
« Last Edit: August 28, 2007, 08:10:32 PM by taner »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to construct a selection?
« Reply #1 on: August 27, 2007, 07:47:46 AM »

What have you tried ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to construct a selection?
« Reply #2 on: August 27, 2007, 08:18:07 AM »
It is a complicated solution for arcs & ellipses.
Look here: http://tinyurl.com/37g3dc

And here: Link to Stig's site
http://intervision.hjem.wanadoo.dk/
Look a "selections" "By Code"
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: How to construct a selection?
« Reply #3 on: August 27, 2007, 01:16:07 PM »
Hi,

Here's my way, it works with circles, ellipses and lwpolylines with arcs, creating a list of points (curves are 'segmented') to be used with polygon selection method (window or crossing)
SelByObj is a sub-routine, ssoc and ssow two examples using SelByObj.

Code: [Select]
;;; SelByObj -Gilles Chanteau- 10/06/2006
;;; Creates a selection set from an object (circle ellipse or closed
;;; lwpolyline) by Window polygon or Crossing Polygon.
;;;
;;; Arguments :
;;; - ent: ename or vla-object
;;; - opt: selection mode (Cp or Wp)
;;; - fltr: selection filter or nil
;;;
;;; Added a ZoomExtents to select objects out of the viewport (07/20/2007)

(defun SelByObj (ent opt fltr / obj dist n lst prec dist p_lst ss)
  (vl-load-com)
  (if (= (type ent) 'ENAME)
    (setq obj (vlax-ename->vla-object ent))
    (setq obj ent
  ent (vlax-vla-object->ename ent)
    )
  )
  (cond
    ((member (vla-get-ObjectName obj) '("AcDbCircle" "AcDbEllipse"))
     (setq dist (/ (vlax-curve-getDistAtParam
     obj
     (vlax-curve-getEndParam obj)
   )
   50
)
   n 0
     )
     (repeat 50
       (setq
lst
  (cons
    (trans
      (vlax-curve-getPointAtDist obj (* dist (setq n (1+ n))))
      0
      1
    )
    lst
  )
       )
     )
    )
    ((and (= (vla-get-ObjectName obj) "AcDbPolyline")
  (= (vla-get-Closed obj) :vlax-true)
  )
     (setq p_lst (vl-remove-if-not
   '(lambda (x)
      (or (= (car x) 10)
  (= (car x) 42)
      )
    )
   (entget ent)
)
     )
     (while p_lst
       (setq
lst
  (cons
    (trans (append (cdr (assoc 10 p_lst))
(list (cdr (assoc 38 (entget ent))))
)
ent
1
    )
    lst
  )
       )
       (if (/= 0 (cdadr p_lst))
(progn
   (setq prec (1+ (fix (* 25 (sqrt (abs (cdadr p_lst))))))
dist (/ (- (if (cdaddr p_lst)
      (vlax-curve-getDistAtPoint
obj
(trans (cdaddr p_lst) ent 0)
      )
      (vlax-curve-getDistAtParam
obj
(vlax-curve-getEndParam obj)
      )
    )
    (vlax-curve-getDistAtPoint
      obj
      (trans (cdar p_lst) ent 0)
    )
)
prec
      )
n    0
   )
   (repeat (1- prec)
     (setq
       lst (cons
     (trans
(vlax-curve-getPointAtDist
   obj
   (+ (vlax-curve-getDistAtPoint
obj
(trans (cdar p_lst) ent 0)
      )
      (* dist (setq n (1+ n)))
   )
)
0
1
       )
     lst
   )
     )
   )
)
       )
       (setq p_lst (cddr p_lst))
     )
    )
  )
  (cond
    (lst
     (vla-ZoomExtents (vlax-get-acad-object))
     (setq ss (ssget (strcat "_" opt) lst fltr))
     (vla-ZoomPrevious (vlax-get-acad-object))
     ss
    )
  )
)

;;; Examples :

;;; SSOC Selection by Crossig

(defun c:ssoc (/ ss opt)
  (sssetfirst nil nil)
  (if (setq ss (ssget "_:S:E"
      (list
'(-4 . "<OR")
'(0 . "CIRCLE")
'(-4 . "<AND")
'(0 . "ELLIPSE")
'(41 . 0.0)
(cons 42 (* 2 pi))
'(-4 . "AND>")
'(-4 . "<AND")
'(0 . "LWPOLYLINE")
'(-4 . "&")
'(70 . 1)
'(-4 . "AND>")
'(-4 . "OR>")
      )
       )
      )
    (sssetfirst
      nil
      (ssdel (ssname ss 0) (SelByObj (ssname ss 0) "Cp" nil))
    )
  )
  (princ)
)

;;; SSOW Selection by Window

(defun c:ssow (/ ss opt)
  (sssetfirst nil nil)
  (if (setq ss (ssget "_:S:E"
      (list
'(-4 . "<OR")
'(0 . "CIRCLE")
'(-4 . "<AND")
'(0 . "ELLIPSE")
'(41 . 0.0)
(cons 42 (* 2 pi))
'(-4 . "AND>")
'(-4 . "<AND")
'(0 . "LWPOLYLINE")
'(-4 . "&")
'(70 . 1)
'(-4 . "AND>")
'(-4 . "OR>")
      )
       )
      )
    (sssetfirst nil (SelByObj (ssname ss 0) "Wp" nil))
  )
  (princ)
)
Speaking English as a French Frog

Fatty

  • Guest
Re: How to construct a selection?
« Reply #4 on: August 27, 2007, 03:24:35 PM »

Maverick®

  • Seagull
  • Posts: 14778
Re: How to construct a selection?
« Reply #5 on: August 27, 2007, 05:48:36 PM »
There is a closed entity such as circle/ellipse/*polyline,How to construct a selection that all member of the selection are in the closed entity,except intersection point on the closed entity?

Hi
See my reply on augi.com

~'J'~

From ^^^^^^ there
Hi,
See my reply in TheSwamp

 :roll:

Fatty

  • Guest
Re: How to construct a selection?
« Reply #6 on: August 27, 2007, 06:07:52 PM »
Yes... just for fun :)

~'J'~

taner

  • Guest
Re: How to construct a selection?
« Reply #7 on: August 29, 2007, 08:18:57 AM »

What have you tried ?


Thanks all first!
Already upload the attached drawing and I have explain what I want again on the 1st floor.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to construct a selection?
« Reply #8 on: August 29, 2007, 10:06:01 AM »
Testing your drawiing, gile's worked & Fatty's only selected the objects that were completely in the circle.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

taner

  • Guest
Re: How to construct a selection?
« Reply #9 on: August 29, 2007, 08:29:20 PM »
None of above works correctly!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to construct a selection?
« Reply #10 on: August 29, 2007, 08:32:25 PM »

Please Explain !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

taner

  • Guest
Re: How to construct a selection?
« Reply #11 on: August 29, 2007, 08:34:47 PM »
I have test above routing,but all of them only selected the objects that were completely in the circle.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to construct a selection?
« Reply #12 on: August 29, 2007, 08:39:05 PM »
There is a closed entity such as circle/ellipse/*polyline,How to construct a selection that all member of the selection are in the closed entity,except intersection point on the closed entity?

..................

Seems to me you got what you asked for. yes ?
« Last Edit: August 29, 2007, 08:40:24 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

taner

  • Guest
Re: How to construct a selection?
« Reply #13 on: August 29, 2007, 08:47:13 PM »
There is a closed entity such as circle/ellipse/*polyline,How to construct a selection that all member of the selection are in the closed entity,except intersection point on the closed entity?

..................

Seems to me you got what you asked for. yes ?

no,I am still looking for the answer. I always can not express what I want clearly because of my poor english. sorry.

Strucmad

  • Guest
Re: How to construct a selection?
« Reply #14 on: August 29, 2007, 09:02:02 PM »
Taner, maybe a screen shot of what you would like might be easier. :-)