autolisp语言编写的程序出错 请高手修改下

(defunc:gear()(setpos(getvar"osmode"))(setvar"osmode"0)(setqm(getreal"输入模数:M=")z(geti... (defun c:gear()
(setp os(getvar"osmode"))
(setvar"osmode"0)
(setq m(getreal"输入模数:M=")
z(getint"输入齿轮:Z=")
h(getreal"输入齿轮宽度:H=")
zj(getreal"输入齿轮轴径:ZJ=")
lf(getreal"输入齿轮厚度:LF=")
)
(if(>h lf)(progn
(setq gr(getreal"输入轮毂端面半径:gr="))

(setq yr(getreal"输入轮缘端面半径:yr="))

(setq s(/(- h lf)2))

(setq l(- h s))
)
)
(setq rf(/(*(- z 2.5)m)2)
rj(/(* m z 0.939693)2)
r(/(* z m)2)
ra(/(*(+z2)m)2)
tt(* m pi)
pj(/36.0z)
a(/(* 1.25m)(cos(*20(/pi 180))))
pt0(list200.0 30.0 0.0)
pt1(polar pt0 0(/tt4))
pt2(polar pt0 pi(/tt4))
pt3(polar pt1 (* 110(/pi 180))a)
pt5(polar pt1 (* -70(/pi 180))a)
pt4(polar pt2 (* 70(/pi 180))a)
pt6(polar pt2 (* 250(/pi 180))a)
pt7(polar pt6 (* -90(/pi 180))2)
)
(command "layer" "m" "11" "c" 1 "" ""
"layer" "m" "12" "c" 2 "" ""
"layer" "m" "13" "c" 252 "" ""
"layer" "s" "13" ""
"pline" pt7 pt6 pt4 pt3 pt5
)
(setq i 1)
(while (<=i 7)
(setq pt6(polar pt6 0 tt)
pt4(polar pt4 0 tt)
pt3(polar pt3 0 tt)
pt5(polar pt5 0 tt)
)
(command pt7 pt6 pt4 pt3 pt5)
(setq i(+i 1))
)
(setq pt8 (polar pt5(*-90(/pi 180))2))
(command pt8 "c")
(setq pt(polar pt0(* 180(/pi 180))(*4 tt)))
(command "move" "1" ""pt0 pt)
(setq e0(entlast))
(command "layer" "s" 11"")
(setq p0(polar pt0(* 90(/pi 180))r))
(command "circle"p0 ra)
(command "region" "1" "")
(setq e10(entlast))
(command "layer" "s" "12" "")
(setq j 1)
(while (<=j z)
(setq i 1)
(while (<=i 10)
(command "rotate"e10""p0 pj)
(setq yd(*r pj(/pi 180)i))
(setq pt(polar pt0 0 yd))
(command "copy" e0"" pt0 pt)
(command "region" "1" "")
(setq e1(entlast))
(command "subtract" e10""e1"")
(setq i(+i 1))
)
(setq j(+j 1))
)
(command "layer" "s" "11" "")
(command "extrude" e10""h 0)
(setq e5(entlast))
(command "erase" e0"")
(if(>h if(progn
(command "circle"p0 yr)
(setq e1(entlast))
(command "extrude" e1""s 5)
(setq e1(entlast))
(command "circle"p0 gr)
(setq e2(entlast))
(command "extrude" e2""s -5)
(setq e2(entlast))
(command "subtract" e1 ""e2"")
(setq pt(list(car p0)(car(cdr p0))h))
(setq s(-0 s)
(command "circle"pt yr)
(setq e3(entlast))
(command "extrude" e3""s 10)
(setq e3(entlast))
(command "circle"pt gr)
(setq e4(entlast))
(command "extrude" e4""s -10)
(setq e4(entlast))
(command "subtract" e3 ""e4"")
(command "cylinder" p0(/zj 2)h)
(setq e4(entlast))
(command "subtract" e5 ""e1 e3 e4"")
)
(progn(command "cylinder" p0(/zj 2)h)
(setq e4(entlast))
(command "subtract" e5 ""e4"")
)
)
(setvar "osmode" os)
)
如果有谁有用autolisp编写的关于直尺圆柱齿轮的程序,麻烦发到邮箱kelaode308@sina.com,谢谢,采纳后会追加悬赏
展开
 我来答
黄涸
推荐于2016-09-16 · TA获得超过1.3万个赞
知道小有建树答主
回答量:1429
采纳率:72%
帮助的人:196万
展开全部
(defun c:3dc()
(setq os(getvar "osmode"))
(setvar "osmode" 0)
(setq m(getreal"输入模数:M=")
z(getint"输入齿数:Z=")
h(getreal"输入齿轮宽度:H=")
zj(getreal"输入齿轮轴径:ZJ=")
lf(getreal"输入轮辐厚度(无轮辐结构时输入齿轮宽度):LF=")
)
(if (> h lf) (progn
(setq gr(getreal"输入轮毂端面半径:gr="))
(setq yr(getreal"输入轮缘端面半径:yr="))
(setq s(/ (- h lf) 2))
(setq l(- h s))
)
)
(setq rf(/ (* (- z 2.5) m) 2)
rj(/ (* m z 0.939693) 2)
r (/ (* z m) 2)
ra(/ (* (+ z 2) m) 2)
tt(* m pi)
pj(/ 36.0 z)
a (/ (* 1.25 m) (cos (* 20 (/ pi 180))))
pt0(list 200.0 30.0 0.0)
pt1(polar pt0 0 (/ tt 4))
pt2(polar pt0 pi (/ tt 4))
pt3(polar pt1 (* 110 (/ pi 180)) a)
pt5(polar pt1 (* -70 (/ pi 180)) a)
pt4(polar pt2 (* 70 (/ pi 180)) a)
pt6(polar pt2 (* 250 (/ pi 180)) a)
pt7(polar pt6 (* -90 (/ pi 180)) 2)
)
(command "layer" "m" "11" "c" 1 "" ""
"layer" "m" "12" "c" 2 "" ""
"layer" "m" "13" "c" 252 "" ""
"layer" "s" "13" ""
"pline" pt7 pt6 pt4 pt3 pt5
)
(setq i 1)
(while (<= i 7)
(setq pt6(polar pt6 0 tt)
pt4(polar pt4 0 tt)
pt3(polar pt3 0 tt)
pt5(polar pt5 0 tt)
)
(command pt6 pt4 pt3 pt5)
(setq i(+ i 1))
)
(setq pt8(polar pt5 (* -90 (/ pi 180)) 2))
(command pt8 "c")
(setq pt(polar pt0 (* 180 (/ pi 180)) (* 4 tt)))
(command "move" "l" "" pt0 pt)
(setq e0(entlast))
(command "layer" "s" 11 "")
(setq p0(polar pt0 (* 90 (/ pi 180)) r))
(command "circle" p0 ra)
(command "region" "l" "")
(setq e10 (entlast))
(command "layer" "s" "12" "")
(setq j 1)
(while (<= j z)
(setq i 1)
(while (<= i 10)
(command "rotate" e10 "" p0 pj)
(setq yd(* r pj (/ pi 180) i))
(setq pt(polar pt0 0 yd))
(command "copy" e0 "" pt0 pt)
(command "region" "l" "")
(setq e1(entlast))
(command "subtract" e10 "" e1 "")
(setq i (+ i 1))
)
(setq j(+ j 1))
)
(command "layer" "s" "11" "")
(command "extrude" e10 "" h 0)
(setq e5 (entlast))
(command "erase" e0 "")
(if (> h lf)(progn
(command "circle" p0 yr)
(setq e1(entlast))
(command "extrude" e1 "" s 5)
(setq e1(entlast))
(command "circle" p0 gr)
(setq e2(entlast))
(command "extrude" e2 "" s -5)
(setq e2(entlast))
(command "subtract" e1 "" e2 "")
(setq pt(list (car p0) (car (cdr p0)) h))
(setq s(- 0 s))
(command "circle" pt yr)
(setq e3(entlast))
(command "extrude" e3 "" s 10)
(setq e3(entlast))
(command "circle" pt gr)
(setq e4(entlast))
(command "extrude" e4 "" s -10)
(setq e4 (entlast))
(command "subtract" e3 "" e4 "")
(command "cylinder" p0 (/ zj 2) h)
(setq e4(entlast))
(command "subtract" e5 "" e1 e3 e4 "")
)
(progn (command "cylinder" p0 (/ zj 2) h)
(setq e4(entlast))
(command "subtract" e5 "" e4 "")
)
)
(setvar "osmode" os)
)

你上面的代码漏得一蹋糊涂!
弄个新的
这个命令是3DC

调试成功 要加分呀!
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式