Good day everyone,
I've created some code (with also the help of AI) that lets me put predefined blocks on circles, the result is almost exactly what I need. However, when I run the program, it places only the block named M5 on all of the selected circles. What I need is for the program to detect the circles based on its diameter then placed a block accordingly. For instance, the circle with Ø5.5 will be placed with block named M5; Ø6.50 with M6; Ø8.5 with M8. I also wanted to delete the original circle. Can someone please help me? Please see images below for reference. Thank you in advance.
(defun c:INSCRW (/ ss ent center)
(setq ss (ssget '((0 . "CIRCLE"))))
(if ss
(repeat (sslength ss)
(setq ent (ssname ss 0))
(setq center (cdr (assoc 10 (entget ent))))
(setq diameter (cdr (assoc 40 (entget ent)))) ; Get circle diameter
; Determine the block name based on diameter
(setq M5
(cond
((= diameter 5.5) "M5")
(t "M5"))) ; Default block name if diameter doesn't match
; Insert the block
(command "insert" M5 center 1.0 0.0)
; Determine the block name based on diameter
(setq M6
(cond
((= diameter 6.5) "M6")
(t "M6"))) ; Default block name if diameter doesn't match
; Insert the block
(command "insert" M6 center 1.0 0.0)
; Delete the original circle
(setq ss (ssdel ent ss))
)
(princ "\\nNo circles found.")
)
(princ)
)
