AUTO CAD Lisp代码总是出现 参数太多的问题

(defunc:lss()(command"layer""m""center""c""red""""1""center""""")(setqp0(getpoint"inp... (defun c:lss() (command "layer" "m" "center" "c" "red" "" "1" "center" "" "") (setq p0(getpoint "input a base point:")) (setq d(getreal "d=:")) (setq ld(getreal "ld=:")) (if(> ld (* 2 d) (princ"ok") (setq ld (* 2 d))) (setq p1 (polar p0 (* 0.5 pi) (* 0.5 d))) (setq p2 (polar p1 0 (- ld (* 2 d)))) (setq p3 (polar p1 0 (- ld (* 0.1 d)))) (setq p4 (polar p2 0 (- (* 0.5 pi)) (* 0.1 d))) (setq p5 (polar p4 0 (* 2 d))) (setq p6 (polar p0 0 ld)) (setq p7 (polar p0 0 (- ld (* 0.1 d)))) (setq p8 (polar p0 0 (- ld (* 2 d)))) (setq p9 (polar p0 (* 0.5 pi) d)) (setq p10 (polar p9 pi (* 0.7 d))) (setq p11 (polar p1 pi (* 0.7 d))) (setq p12 (polar p0 pi (* 0.7 d))) (setq p13 (polar p0 pi (* 0.9 d))) (setq p14 (polar p0 0 (+ ld (* 0.2 d)))) (setq ss(getvar "clayer")) (setvar "clayer" "center") (command "line" p13 p14 "") (setvar "clayer" "thick") (command "pline" p0 "w" 0.2 0.2 p9 p10 p12 "") (command "line" p11 p3 p5 p6 "") (command "line" p2 p8 "" "line" p3 p7 "") (setvar "clayer" "thin") (command "mirror" "c" p6 p10 "" p0 p6 "n") (setvar "clayer" ss) (princ) )) 展开
 我来答
dnbc1
2013-11-23 · TA获得超过978个赞
知道小有建树答主
回答量:1235
采纳率:92%
帮助的人:406万
展开全部
改为如下一试:
(defun c:lss()
(command "layer" "m" "center" "c" "red" "" "1" "center" "" "")
(setq p0(getpoint "input a base point:"))
(setq d(getreal "d=:"))
(setq ld(getreal "ld=:"))
(if(> ld (* 2 d)) (princ"ok") (setq ld (* 2 d)))
(setq p1 (polar p0 (* 0.5 pi) (* 0.5 d)))
(setq p2 (polar p1 0 (- ld (* 2 d))))
(setq p3 (polar p1 0 (- ld (* 0.1 d))))
(setq p4 (polar p2 0 (- (* 0.5 pi)) (* 0.1 d)))
(setq p5 (polar p4 0 (* 2 d)))
(setq p6 (polar p0 0 ld))
(setq p7 (polar p0 0 (- ld (* 0.1 d))))
(setq p8 (polar p0 0 (- ld (* 2 d))))
(setq p9 (polar p0 (* 0.5 pi) d))
(setq p10 (polar p9 pi (* 0.7 d)))
(setq p11 (polar p1 pi (* 0.7 d)))
(setq p12 (polar p0 pi (* 0.7 d)))
(setq p13 (polar p0 pi (* 0.9 d)))
(setq p14 (polar p0 0 (+ ld (* 0.2 d))))
(setq ss(getvar "clayer"))
(setvar "clayer" "center")
(command "line" p13 p14 "")
(setvar "clayer" "thick")
(command "pline" p0 "w" 0.2 0.2 p9 p10 p12 "")
(command "line" p11 p3 p5 p6 "")
(command "line" p2 p8 "" "line" p3 p7 "")
(setvar "clayer" "thin")
(command "mirror" "c" p6 p10 "" p0 p6 "n")
(setvar "clayer" ss)
(princ)

)
追问

检查没有问题 加载不成  

能不能跟我说你改的代码的哪里然后就没有了参数太多的问题

追答
(if (> ld (* 2 d)  (princ"ok")  (setq ld (* 2 d)))
...
(princ)
)
1、如果是ld>2d就显示OK,否则就让ld=2d,然后往下执行,就是我改的那样。
即:(if (> ld (* 2 d) ---> (if (> ld (* 2 d))

(princ)
) ---> (princ)
也就是:
(if (> ld (* 2 d)) (princ"ok") (setq ld (* 2 d)))
...
(princ)
2、另外一种改法
(if (> ld (* 2 d)) (princ"ok") (progn (setq ld (* 2 d))
...
(princ)
)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式