Author Topic: Selection set  (Read 1128 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Selection set
« on: July 12, 2017, 09:01:06 AM »
How would I go about creating a selection set that would include a circle (if it exists) and anything inside it and return the diameter as a variable to be used later in a routine? This has me stumped.
Thanks for any ideas.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Selection set
« Reply #1 on: July 12, 2017, 09:10:52 AM »
First thing that comes to mind is pick the circle, trace it with points then use ssget "WP".

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Selection set
« Reply #2 on: July 26, 2017, 03:19:08 PM »
Here's and oldie from my CAD library. Change the line with (setq ss (ssget "CP" ptlst)) to "WP" to select all inside only. You can also increase or decrease the accuracy by changing the value of the "inc" variable.
Code - Auto/Visual Lisp: [Select]
  1. ;; ----- (pjk-ssget-cir [Entity Name]) ----------------
  2. ;; This function selects all the objects within or crossing a
  3. ;; circle with the [Entity Name] given. Returns the resulting
  4. ;; selection set.
  5. (defun pjk-ssget-cir (enam / cnt cen elst ful inc pt ptlst rad ss)
  6.         (if enam
  7.                 (progn
  8.                         (setq elst (entget enam) ptlst nil
  9.                                 cen (trans (cdr (assoc 10 elst)) enam 0)
  10.                                 rad (cdr (assoc 40 elst))
  11.                                 inc 1.0
  12.                                 ful (/ 360.0 inc)
  13.                                 cnt 0.0
  14.                         )
  15.                         ;; Created a Point list for 360 points on curcumference of
  16.                         ;; the circle to use with "Crossing Polygon" selection.
  17.                         (while (< cnt ful)
  18.                                 (setq pt (polar cen (pjk-dtr cnt) rad)
  19.                                         ptlst (cons pt ptlst)
  20.                                         cnt (+ inc cnt)
  21.                                 )
  22.                         )
  23.                         (reverse ptlst)
  24.                         ;; Delete the circle.
  25.                         (entdel enam)
  26.                         ;; Select by Crossing polygon.
  27.                         (setq ss (ssget "CP" ptlst))
  28.                         ;; Undelete the Circle.
  29.                         (entdel enam)
  30.                         ss
  31.                 )
  32.                 nil
  33.         )
  34. ) ;; End Function (pjk-ssget-cir)
  35.  
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt