AutoCAD LISP 循环选择语句cond,相比if语句更加简洁,代码如下。
(defun c:test()
(initget "A0 A1 A2 A3 A4")
(setq size (getkword "请输入图纸大小A0,A1,A2,A3,A4<A3>:"))
(if (= size nil) (setq size "A3"))
(setq size (strcase size))
(cond ((= size "A0") (setq p2 '(1189 841)))
((= size "A1") (setq p2 '(841 594)))
((= size "A2") (setq p2 '(594 420)))
((= size "A3") (setq p2 '(420 297)))
((= size "A4") (setq p2 '(297 210)))
(t (setq p2 '(420 297)))
)
(setq p1 '(0 0))
(command "rectang" p1 p2)
(command "zoom" "A")
(prin1)
)
代码完。