程序本身的问题就
(repeat n2 ...) 应该为(repeat (fix n2)...)
最后的erase选择对象后需要回车。
就功能上,不知你想干什么,一条从Q2到Q3的直线为什么要重复画那么多遍?
你是想将某一直线打散成某一长度的线段吗?
程序循环中注意n2是不会变化的,你必须自己设置一个变量来产生变化。
修改后如下:
- (defun c:mc()
- (setq l1 (entsel "请选择直线:"))
- (setq l1_data (entget (car l1)))
- (setq pts (assoc 10 l1_data))
- (setq p1 (cdr pts))
- (setq pte (assoc 11 l1_data))
- (setq p2 (cdr pte))
- (setq ang (angle p1 p2))
- (setq dd (distance p1 p2))
- (setq n1 (rem dd 2.4))
- (setq n2 (/ (- dd n1) 2.4))
- (setq p0 (polar p1 ang n1))
- (setq i n2)
- (repeat (fix n2)
- (setq q1 (polar p0 ang (* 2.4 i)))
- (setq q2 (polar p0 ang (- (* 2.4 i) 0.8)))
- (setq q3 (polar p0 ang (- (* 2.4 i) 2.4)))
- (command "line" q3 q2 "")
- (setq i (1- i))
- )
- (command "line" p1 p0 "")
- (command "erase" l1 "")
- (princ)
- )
|