Autolisp 帮解决下难题
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 16:30:50
Autolisp 帮解决下难题
(defun c:yzluow(/)
(setq b1(getpoint"指定基点:"))
(setq r1(getreal"\n指定初始半径:"))
(setq disp(getreal"\n指定节距:"))
(setq angtg(getreal"\n输入圆形角:"))
(setq m(getreal"\n输入圈数:"))
(setq n(getreal"\n输入每圈细化段数:"))
(cond ((null n) (setq n 36)))
(setq delta(/(* 2 pi) n))
(setq j(/ disp n))
(setq bb(caddr b1))
(setq tg(*(/ angta 180) pi))
(setq ang 0)
(setq k 0)
(command "ucs" "o" b1)
(command "3dpoly" (list r1 0 0))
(repeat (* m n))
(setq k(+ k 1))
(setq ang(+ delta ang))
(setq r(- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg)))))
(setq pt2(list (* r (cos ang)) (* r (sin ang)) (+ 0 (* j k))))
(command pt2)
)
(command "")
)
运行后 提示
错误:SETQ 中变量名称错误:(SETQ PT1 (LIST (* R (COS ANG)) (* R (SIN
ANG)) (+ 0 (* J K)))) 怎么回事 能帮改改么
(defun c:yzluow(/)
(setq b1(getpoint"指定基点:"))
(setq r1(getreal"\n指定初始半径:"))
(setq disp(getreal"\n指定节距:"))
(setq angtg(getreal"\n输入圆形角:"))
(setq m(getreal"\n输入圈数:"))
(setq n(getreal"\n输入每圈细化段数:"))
(cond ((null n) (setq n 36)))
(setq delta(/(* 2 pi) n))
(setq j(/ disp n))
(setq bb(caddr b1))
(setq tg(*(/ angta 180) pi))
(setq ang 0)
(setq k 0)
(command "ucs" "o" b1)
(command "3dpoly" (list r1 0 0))
(repeat (* m n))
(setq k(+ k 1))
(setq ang(+ delta ang))
(setq r(- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg)))))
(setq pt2(list (* r (cos ang)) (* r (sin ang)) (+ 0 (* j k))))
(command pt2)
)
(command "")
)
运行后 提示
错误:SETQ 中变量名称错误:(SETQ PT1 (LIST (* R (COS ANG)) (* R (SIN
ANG)) (+ 0 (* J K)))) 怎么回事 能帮改改么
程序中变量名前后不一致,有多")"和少")"现象,应如下:
(defun c:yzluow(/)
(setq r1(getreal"\n指定初始半径:"))
(setq disp(getreal"\n指定节距:"))
(setq angtg(getreal"\n输入圆形角:"))
;(setq m(getreal"\n输入圈数:"))
;(setq n(getreal"\n输入每圈细化段数:"))
;因为repeat后面要求跟整数,所以这两行应改为如下:
(setq m(getint "\n输入圈数:"))
(setq n(getint "\n输入每圈细化段数:"))
(cond ((null n) (setq n 36)))
(setq delta(/(* 2 pi) n))
(setq j(/ disp n))
(setq bb(caddr b1))
;(setq tg(*(/ angta 180) pi));变量错,应为
(setq tg(*(/ angtg 180) pi))
(setq ang 0)
(setq k 0)
(command "ucs" "o" b1)
(command "3dpoly" (list r1 0 0))
;(repeat (* m n));最后面多一个")"
(repeat (* m n)
(setq k (+ k 1))
(setq ang (+ delta ang))
;(setq r(- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg)))));最后面少一个")"
(setq r (- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg))))))
(setq pt2 (list (* r (cos ang)) (* r (sin ang)) (+ 0.0 (* j k))))
(command pt2)
)
(command "")
(princ)
)
(defun c:yzluow(/)
(setq r1(getreal"\n指定初始半径:"))
(setq disp(getreal"\n指定节距:"))
(setq angtg(getreal"\n输入圆形角:"))
;(setq m(getreal"\n输入圈数:"))
;(setq n(getreal"\n输入每圈细化段数:"))
;因为repeat后面要求跟整数,所以这两行应改为如下:
(setq m(getint "\n输入圈数:"))
(setq n(getint "\n输入每圈细化段数:"))
(cond ((null n) (setq n 36)))
(setq delta(/(* 2 pi) n))
(setq j(/ disp n))
(setq bb(caddr b1))
;(setq tg(*(/ angta 180) pi));变量错,应为
(setq tg(*(/ angtg 180) pi))
(setq ang 0)
(setq k 0)
(command "ucs" "o" b1)
(command "3dpoly" (list r1 0 0))
;(repeat (* m n));最后面多一个")"
(repeat (* m n)
(setq k (+ k 1))
(setq ang (+ delta ang))
;(setq r(- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg)))));最后面少一个")"
(setq r (- r1 (* (+ 0 (* j k) (/ ( sin tg) (cos tg))))))
(setq pt2 (list (* r (cos ang)) (* r (sin ang)) (+ 0.0 (* j k))))
(command pt2)
)
(command "")
(princ)
)