lisp 圆大小排列问题
(if (and(setq ss (ssget "x"(list(cons 8 "1")))) )
(progn
(setq i 0 clst (list))
(repeat (sslength ss)
(setq en (ssname ss i)
ent (entget en)
r1 (assoc 40 ent)
i (1+ i))
(if (not (member (cdr r1) clst))
(progn
(setq ss1 (ssget "x"(list(cons 8 "1")r1)))
(setq r (assoc 40 ent))
(setq newd (getdist (strcat "\n直径-->" (rtos (* (cdr r) 2) 2 4) "<--:")))
(if newd (progn
(setq j 0)
(setq r (/ newd 2))
(setq clst (cons r clst))
(repeat (sslength ss1)
(setq ent1 (entget(ssname ss1 j))
ent1 (subst (cons 40 r) (assoc 40 ent1) ent1)
j (1+ j))
(entmod ent1)
)
))
))
)
)
)
(princ)
)
上面改圆大小的程序 目前程序对圆没有排列
帮忙修改一下从最小直径往大的排列?
谢谢
结果:从5,6,8,9,10,15,16 展开
(defun c:bcnc ( / li et clst cenlist )
(if (and(setq ss (ssget "x"(list(cons 8 "1")))) )
(progn
(setq i 0 clst (list) cenlist nil)
(repeat (sslength ss)
(setq en (ssname ss i)
ent (entget en)
r1 (assoc 40 ent)
cenlist (cons(cdr r1) cenlist)
i (1+ i))
(setq cenlist (vl-sort cenlist '< ))
)
(foreach e cenlist
(if (not (member e clst));(setq e (nth 0 cenlist))
(progn
(setq ss1 (ssget "x"(list(cons 8 "1") (cons 40 e))))
;(setq r (assoc 40 ent))
(setq newd (getdist (strcat "\n直径-->" (rtos (* e 2) 2 4) "<--:")))
(if newd (progn
(setq j 0)
(setq e (/ newd 2))
(setq clst (cons e clst))
(repeat (sslength ss1)
(setq ent1 (entget(ssname ss1 j))
ent1 (subst (cons 40 e) (assoc 40 ent1) ent1)
j (1+ j))
(entmod ent1)
)
))
))
)
)
)
(princ)
)
应该是这个意思吧,你自己测试一下。
(defun c:bcnc ( / li et clst cenlist l2 )
(if (and(setq ss (ssget "x"(list(cons 8 "1")))) )
(progn
(setq i 0 clst nil cenlist nil l2 nil)
(repeat (sslength ss)
(setq en (ssname ss i)
ent (entget en)
r1 (assoc 40 ent)
cenlist (cons(cdr r1) cenlist)
i (1+ i))
(setq cenlist (vl-sort cenlist '" (rtos (* e 2) 2 4) "<--:")))
(if newd (progn
(setq j 0)
(setq e (/ newd 2))
(setq clst (cons e clst))
(repeat (sslength ss1)
(setq ent1 (entget(ssname ss1 j))
ent1 (subst (cons 40 e) (assoc 40 ent1) ent1)
j (1+ j))
(entmod ent1)
)
))
))
)
)
)
(princ)
)