编了个双向偏移的小程序,却无法完美执行,求大神指点
本帖最后由 satin 于 2016-7-31 23:13 编辑;本意是定义一个函数std,对线段进行两个方向便移,这里已设定偏移值为100。
;但是下面的代码有时候执行,有时候不执行。有时候执行的很乱。
代码附在文后。
以下是执行的截图说明。
【代码全文】
(defun c:std()
(setq width 100.0)
(setq sl (ssget '((0 . "line"))));以交互方式得到一个选择集,图元类型限定为line。
(setq ntotal (sslength sl))
(setq n 0)
(while (< n ntotal);
(progn
(setq e (ssname sl n)
el (entget e)
p1 (cdr (assoc 10 el))
p2 (cdr (assoc 11 el))
alf (angle p1 p2) ;polar函数中的旋转角度是从ucs的正方向算起,所以需要算出并加上基础直线的方向角。
a90 (+ alf (angtof "90.0"))
a270 (+ alf (angtof "270.0"));计算line方向旋转90度和270度后与x轴夹角
p3 (polar p1 a90 width)
p4 (polar p2 a90 width)
p5 (polar p1 a270 width)
p6 (polar p2 a270 width)
)
(command "line" p3 p4 "");一个command语句是否只能使用一次AutoCAD命令
(command "line" p5 p6 "")
)
(setq n (1+ n))
)
princ()
)
捕捉模式得关闭
可改用 entmake 函数 Andyhon 发表于 2016-7-31 21:37 static/image/common/back.gif
捕捉模式得关闭
可改用 entmake 函数
orz, 大神你真是一针见血啊。厉害。
页:
[1]