Author Topic: Selection set  (Read 245 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Bull Frog
  • Posts: 422
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: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

PKENEWELL

  • Newt
  • Posts: 158
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. (setq elst (entget enam) ptlst nil
  8. cen (trans (cdr (assoc 10 elst)) enam 0)
  9. rad (cdr (assoc 40 elst))
  10.                                inc 1.0
  11.                                ful (/ 360.0 inc)
  12. cnt 0.0
  13. )
  14. ;; Created a Point list for 360 points on curcumference of
  15. ;; the circle to use with "Crossing Polygon" selection.
  16. (while (< cnt ful)
  17. (setq pt (polar cen (pjk-dtr cnt) rad)
  18. ptlst (cons pt ptlst)
  19. cnt (+ inc cnt)
  20. )
  21. )
  22. (reverse ptlst)
  23. ;; Delete the circle.
  24. (entdel enam)
  25. ;; Select by Crossing polygon.
  26. (setq ss (ssget "CP" ptlst))
  27. ;; Undelete the Circle.
  28. (entdel enam)
  29. ss
  30. )
  31. nil
  32. )
  33. ) ;; End Function (pjk-ssget-cir)
  34.  
"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