【发布时间】:2019-03-10 21:28:37
【问题描述】:
一个简单的循环程序可以用作:
(setq y 0)
(while (< q 12) (setq q (1+ q))
(print "Hello")
)
但是如何在 Autocad 命令中使用这样的循环呢?
我相信下面的代码可以使用循环来简化,但如何在运行命令中使用它们。
(defun PX (_angle)
(list (* BaseRadius
(+ (cos (+ 1.570796 _angle)) (* _angle (cos _angle)))
)
(* BaseRadius
(+ (sin (+ 1.570796 _angle)) (* _angle (sin _angle)))
)
)
)
(defun c:cir ()
(setq BaseRadius 8)
(command "_pline"
"qua"
(PX 0)
(PX 0.1)
(PX 0.2)
(PX 0.3)
(PX 0.4)
(PX 0.5)
(PX 0.6)
(PX 0.7)
(PX 0.8)
(PX 0.9)
(PX 1)
(PX 1.1)
(PX 1.2)
(PX 1.3)
(PX 1.4)
(PX 1.5)
""
)
【问题讨论】:
-
在你的第一个例子中,我相信
(setq y 0)实际上应该是(setq q 0) -
是的,必须纠正!