lisp 圆大小排列问题
- 提问者网友:川水往事
- 2021-03-12 15:33
- 五星知识达人网友:北方的南先生
- 2021-03-12 16:03
(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 "
直径-->" (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 '< ))
)
(setq l2 (cons (car cenlist)l2))
(while(setq cenlist (vl-remove(car cenlist)(cdr cenlist)))
(setq l2 (cons(car cenlist) l2))
)
(foreach e (reverse l2)
(if (not (member e clst))
(progn
(setq ss1 (ssget "x"(list(cons 8 "1") (cons 40 e))))
(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)
)追问再次感谢,基本上是可以了,但还是有问题.选择不全
以上是程序 结果
我用例图处理结果是不定性 的少了几种圆径 谢谢
以下是例图中的所含圆种类