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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AUTO CAD Lisp代码总是出现 参数太多的问题相关的知识,希望对你有一定的参考价值。

(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) ))

参考技术A 改为如下一试:
(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)
)

以上是关于AUTO CAD Lisp代码总是出现 参数太多的问题的主要内容,如果未能解决你的问题,请参考以下文章

lisp编程提示参数太多

Auto cad中的LISP语言是啥?有怎样的用途?

cad.net 定义lisp

lisp错误: 参数太多

什么是Auto CAD二次开发教程?

CADlisp编程:如何用lisp处理一个dwg图形中的多个多线段?