Message 1 of 17
Delete everything outside the circle in Lisp.

Not applicable
11-21-2017
01:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
My task is to create circle, then create some triangles inside and outside that circle. Program should let me draw only triangles inside the circle, and delete ones outside the circle.
Here is the code I've done so far. It works fine through X-axis and Y-axis, but sometimes it draws triangle outside the circle.
What is wrong, and how to make everything deleted outside the circle.
(setq center nil) (setq radius nil) (setq l_t nil) (setq h nil) (setq x_max nil) (setq x_min nil) (setq y_max nil) (setq y_min nil) (setq triangle nil) (setq center (getpoint "Circle center")) (setq radius (getpoint "Circle radius")) (command "circle" center radius) (setq circle (entlast)) (setq center_r (cdr(assoc 40 (entget circle)))) ;getting radius (setq x_max (+(nth 0 center) center_r)) (setq x_min (-(nth 0 center) center_r)) (setq y_max (+(nth 1 center) center_r)) (setq y_min (-(nth 1 center) center_r)) (repeat (getint "How many triangles?") (setq center_t (getpoint "Set the center")) (setq h (getpoint "Set the height")) (command "._polygon" "3" center_t "I" h) (setq h nil) (if (AND(<(nth 0 center_t) x_max)(>(nth 0 center_t) x_min)) (progn (princ "inside"));progn (entdel (entlast)) );if (if (AND(<(nth 1 center_t) y_max)(>(nth 1 center_t) y_min)) (progn (princ "inside"));progn (entdel (entlast)) );if (setq triangle (append triangle (list (entlast)))) );repeat