That should not be difficult, but a question: What should happen with a selected Circle whose diameter is not within one of those ranges, such as 15, or 23? Nothing? Insert some default none-of-the-above Block? Notify the User?
EDIT: Wait! Relational testing with (-4) entries is powerful enough that it's possible to have it allow selection of only Circles whose diameters fall within those ranges, and ignore others. In simplest terms, and minimally tested:
(defun C:TEST (/ ss n cir rad)
(if
(setq ss
(ssget
'( ; filter list
(0 . "CIRCLE")
(-4 . "<OR")
(-4 . "<AND") (-4 . ">=") (40 . 5.5) (-4 . "<=") (40 . 7.0) (-4 . "AND>")
(-4 . "<AND") (-4 . ">=") (40 . 8.0) (-4 . "<=") (40 . 9.0) (-4 . "AND>")
(-4 . "<AND") (-4 . ">=") (40 . 10.0) (-4 . "<=") (40 . 11.0) (-4 . "AND>")
(-4 . "<AND") (-4 . ">=") (40 . 12.0) (-4 . "<=") (40 . 13.0) (-4 . "AND>")
(-4 . "OR>")
); filter list
); ssget
); setq
(repeat (setq n (sslength ss)); then
(setq
cir (ssname ss (setq n (1- n)))
rad (getpropertyvalue cir "Radius")
); setq
(command "_.insert"
(cond
((<= rad 7.0) "H2")
((<= rad 9.0) "H1")
((<= rad 11.0) "H3")
("H4")
); cond
"_non" (getpropertyvalue cir "Center") "" "" ""
); command
); repeat
); if
(prin1)
)
[Of course that's all based on the radius, not the diameter, because the radius of a Circle is what entity data stores, and therefore is what can be filtered for in (ssget).]
Kent Cooper, AIA