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) ))
展开
1个回答
展开全部
改为如下一试:
(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)
)
(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)
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询