CAD 的autolisp编程问题:我用下面这个程序还去掉重合的点,但这个程序不能够循环。 50
(defunc:ere()(setqa(ssget))(setqi(sslengtha))(while(>i1)(setqj(-i1))(setqb(ssnamea(se...
(defun c:ere()
(setq a (ssget))
(setq i (sslength a))
(while (> i 1)
(setq j (- i 1))
(setq b (ssname a (setq i (1- i))))
(setq c (entget b))
(while (> j 0)
(setq b1 (ssname a (setq j (1- j))))
(setq c1 (entget b1))
(if (and (= (rtos (cadr (assoc 10 c)) 2 4)(rtos (cadr (assoc 10 c1)) 2 4))
(= (rtos (caddr (assoc 10 c)) 2 4)(rtos (caddr (assoc 10 c1)) 2 4)))
(command "erase" b1 "")
)))) 展开
(setq a (ssget))
(setq i (sslength a))
(while (> i 1)
(setq j (- i 1))
(setq b (ssname a (setq i (1- i))))
(setq c (entget b))
(while (> j 0)
(setq b1 (ssname a (setq j (1- j))))
(setq c1 (entget b1))
(if (and (= (rtos (cadr (assoc 10 c)) 2 4)(rtos (cadr (assoc 10 c1)) 2 4))
(= (rtos (caddr (assoc 10 c)) 2 4)(rtos (caddr (assoc 10 c1)) 2 4)))
(command "erase" b1 "")
)))) 展开
5个回答
展开全部
(defun c:ere ( )
(setq ss (ssget (list (cons 0 "POINT"))) li '() si 0 ei 0)
(repeat (sslength ss)
(setq cs (ssname ss si) si (1+ si) ce (entget cs))
(if (member (vl-princ-to-string (cdr (assoc 10 ce))) li)
(progn
(command "_.Erase" cs "")
(setq ei (1+ ei))
)
(setq li (cons (vl-princ-to-string (cdr (assoc 10 ce))) li))
)
)
(princ (strcat "\n在选择的" (itoa (sslength ss)) "个点中,删除了" (itoa ei) "个重复的点!"))
(princ)
)
上面的程序,我用的是REPEAT,用WHILE也是一样的效果。另外,循环里面套循环个人觉得不太可取,若对象过多会运算很大。
(setq ss (ssget (list (cons 0 "POINT"))) li '() si 0 ei 0)
(repeat (sslength ss)
(setq cs (ssname ss si) si (1+ si) ce (entget cs))
(if (member (vl-princ-to-string (cdr (assoc 10 ce))) li)
(progn
(command "_.Erase" cs "")
(setq ei (1+ ei))
)
(setq li (cons (vl-princ-to-string (cdr (assoc 10 ce))) li))
)
)
(princ (strcat "\n在选择的" (itoa (sslength ss)) "个点中,删除了" (itoa ei) "个重复的点!"))
(princ)
)
上面的程序,我用的是REPEAT,用WHILE也是一样的效果。另外,循环里面套循环个人觉得不太可取,若对象过多会运算很大。
展开全部
不妨试试下面的代码:
(defun c:ere()
(setq a (ssget (list(cons 0 "point"))))
(setq i (sslength a))
(setq j (1- i))
(while (> j -1)
(setq b (ssname a j))
(setq c (entget b))
(if (/= c nil)
(progn
(setq zb(cdr (assoc 10 c)))
(setq cfdj(ssget "x" (list (cons 10 Zb)(cons 0 "point"))))
(if (/= cfdj nil)(progn(setq cfdj(ssdel b cfdj))(command "erase" cfdj "")))
)
)
(setq j(1- j))
)
)
(defun c:ere()
(setq a (ssget (list(cons 0 "point"))))
(setq i (sslength a))
(setq j (1- i))
(while (> j -1)
(setq b (ssname a j))
(setq c (entget b))
(if (/= c nil)
(progn
(setq zb(cdr (assoc 10 c)))
(setq cfdj(ssget "x" (list (cons 10 Zb)(cons 0 "point"))))
(if (/= cfdj nil)(progn(setq cfdj(ssdel b cfdj))(command "erase" cfdj "")))
)
)
(setq j(1- j))
)
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以用(repeat (sslength i)
.................)试试,用while循环i值没有在循环体中修正啊,这样不成死循环了。。
.................)试试,用while循环i值没有在循环体中修正啊,这样不成死循环了。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
请问朋友是否有删除重复线的LISP命令
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询