明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2233|回复: 15

齿轮设计程序,高手帮我排几处错吧

  [复制链接]
发表于 2005-5-11 20:03:00 | 显示全部楼层 |阅读模式
;gear.lip (defun grifo()
(setq c(getpoint"\n 齿轮中心: "))
(setq pc(getpoint"\n 节距圆: "))
(setq teeth(getint"\n 齿数: "))
(while(<teeth 14)(setq teeth(getint"\n 必须至少14个齿: ")))
(while(>teeth 50)(setq teeth(getint"\n 必须不超过50个齿: ")))
(while(<teeth 14)(setq teeth(getint"\n 必须至少14个齿: ")))
(while(>teeth 50)(setq teeth(getint"\n 必须不超过50个齿: ")))
) (defun calgear()
(setq d(* 2(distance c pc)))(setq pc(polar c 0(/ d 2)))
(setq ang32.79248)
(setq ang5(/360.000000 teeth))
(setq wang -0.785385)
(setq wang 20.785385)
(setq dp(/teeth d))
(setq ht(/ 0.32 dp))
(setq adm(/ 1.0 dp))
(setq y(* (/ 2.257 dp) 1.0642))
) (defun drawgear()
(command "PLINE"
(setq p (polar pc 0 anm))
"a"
"ce"
c
"l"
ht
"l"
(setq p (polar(getvar "lastpoint") ang3 y))
"a"
"ce"
c
"l"
ht
"" )
(SETQ TOP (GETVAR "LASTPOINT"))
(command "MIRROR"
"L"
""
(setq p(polar pc 0 adm))
c
"n"
)
(command "ARRAY"
"w"
(POLAR TOP 4.712389(* Y 1.5))
(polar TOP 0 Y)
""
"c"
c
ang5
"-360"
"Y"
)
)
(defun C:GEAR()
(grinfo)
(setq stdots(getvar "blipmode"))
(setq stech(getvar "cmdecho"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
(calgear)
(drawgear)
(setvar "blipmode" stdots)
(setvar "cmdecho" stech)
)
(prompt"\n键入Gear换起命令: ") 这程序我是从书本上搬过来的.,可是调试时候还是有错,说语法错误,我百思不得其解!!! 有劳你们了!!
发表于 2005-5-11 21:44:00 | 显示全部楼层
错误实在太多了,楼主仔细检查一遍再说啊,错误不下于20处。。。。。
发表于 2005-5-12 08:43:00 | 显示全部楼层
主要是空格问题,请楼主仔细检查一下,,,应该没有20处,有些空格省略并不会造成错误
发表于 2005-5-12 09:11:00 | 显示全部楼层
嘿嘿,说得多了一些,暂时先指出这么多吧
  1. (defun grifo ()                                                                       ;_1前后不对应,应该是grinfo
  2.    (setq c (getpoint "\n 齿轮中心: "))
  3.    (setq pc (getpoint "\n 节距圆: "))
  4.    (setq teeth (getint "\n 齿数: "))
  5.    (while (<teeth 14)                                                                     ;_2符号与变量要分开
  6.        (setq teeth (getint "\n 必须至少14个齿: "))
  7.    )
  8.    (while (>teeth 50)                                                                       ;_3符号与变量要分开
  9.        (setq teeth (getint "\n 必须不超过50个齿: "))
  10.    )
  11.    (while (<teeth 14)
  12.        (setq teeth (getint "\n 必须至少14个齿: "))
  13.    )                                                                                                             ;_4这句不明白是什么意思,上面不是有这一句了嘛
  14.    (while (>teeth 50)
  15.        (setq teeth (getint "\n 必须不超过50个齿: "))
  16.    )                                                                                               ;_5这句也一样,多余的吧
  17. )(defun calgear ()
  18.    (setq d (* 2 (distance c pc)))
  19.    (setq pc (polar c 0 (/ d 2)))
  20.    (setq ang3 2.79248)                                                               ;_6变量与值要分开
  21.    (setq ang5 (/ 360.000000 teeth))                             ;_7符号与变量要分开
  22.    (setq wang -0.785385)
  23.    (setq wang 20.785385)                                                   ;_8这句不明白是什么意思
  24.    (setq dp (/ teeth d))                                                             ;_9符号与变量要分开
  25.    (setq ht (/ 0.32 dp))
  26.    (setq adm (/ 1.0 dp))
  27.    (setq y (* (/ 2.257 dp) 1.0642))
  28. )(defun drawgear  ()
  29.    (command "PLINE"
  30.        (setq p (polar pc 0 anm))                                     ;_10变量写错了,应该是adm吧
  31.        "a"
  32.        "ce"
  33.        c
  34.        "l"
  35.        ht
  36.        "l"
  37.        (setq p (polar (getvar "lastpoint") ang3 y))
  38.        "a"
  39.        "ce"
  40.        c
  41.        "l"
  42.        ht
  43.        ""   )
  44.    (SETQ TOP (GETvar "LASTPOINT"))
  45.    (command "MIRROR"
  46.        "L"
  47.        ""
  48.        (setq p (polar pc 0 adm))
  49.        c
  50.        "n"
  51.    )
  52.    (command "ARRAY"
  53.        "w"
  54.        (POLAR TOP 4.712389 (* Y 1.5))
  55.        (polar TOP 0 Y)
  56.        ""
  57.        "c"
  58.        c
  59.        ang5
  60.        "-360"
  61.        "Y"
  62.    )
  63. )
  64. (defun C:GEAR ()
  65.    (grinfo)
  66.    (setq stdots (getvar "blipmode"))
  67.    (setq stech (getvar "cmdecho"))
  68.    (setvar "blipmode" 0)
  69.    (setvar "cmdecho" 0)
  70.    (calgear)
  71.    (drawgear)
  72.    (setvar "blipmode" stdots)
  73.    (setvar "cmdecho" stech)
  74. )
  75. (prompt "\n键入Gear换起命令: ")
 楼主| 发表于 2005-5-12 09:46:00 | 显示全部楼层
多谢各位,小弟在感激的同时又希望大家能继续帮我排忧解难....
 楼主| 发表于 2005-5-12 09:59:00 | 显示全部楼层
这个是我修改过的程序,大家看看还有什么不是对之处,至于那边的重复语句我也不太清楚,书上就是这样的!!
刚刚调试过,还是有语法错误,这程序对我太重要了 ,希望各路高手继续帮小弟一把!!
;gear.lip (defun grinfo()
(setq c(getpoint "\n 齿轮中心: "))
(setq pc(getpoint "\n 节距圆: "))
(setq teeth(getint "\n 齿数: "))
(while(< teeth 14)(setq teeth(getint "\n 必须至少14个齿: ")))
(while(> teeth 50)(setq teeth(getint "\n 必须不超过50个齿: ")))
(while(< teeth 14)(setq teeth(getint "\n 必须至少14个齿: ")))
(while(> teeth 50)(setq teeth(getint "\n 必须不超过50个齿: ")))
) (defun calgear()
(setq d(* 2(distance c pc)))(setq pc(polar c 0(/ d 2)))
(setq ang 32.79248)
(setq ang 5(/ 360.000000 teeth))
(setq wang -0.785385)
(setq wang 20.785385)
(setq dp(/ teeth d))
(setq ht(/ 0.32 dp))
(setq adm(/ 1.0 dp))
(setq y(* (/ 2.257 dp) 1.0642))
) (defun drawgear()
(command "PLINE"
(setq p (polar pc 0 adm))
"a"
"ce"
c
"l"
ht
"l"
(setq p (polar(getvar "lastpoint") ang 3 y))
"a"
"ce"
c
"l"
ht
"" )
(SETQ TOP (GETVAR "LASTPOINT"))
(command "MIRROR"
"L"
""
(setq p(polar pc 0 adm))
c
"n"
)
(command "ARRAY"
"w"
(POLAR TOP 4.712389(* Y 1.5))
(polar TOP 0 Y)
""
"c"
c
ang 5
"-360"
"Y"
)
)
(defun C:GEAR()
(grinfo)
(setq stdots(getvar "blipmode"))
(setq stech(getvar "cmdecho"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
(calgear)
(drawgear)
(setvar "blipmode" stdots)
(setvar "cmdecho" stech)
)
(prompt"\n键入Gear换起命令: ")
发表于 2005-5-12 10:52:00 | 显示全部楼层
修改过了,还有一个BUG,就是图形有重迭部份
  1.           ;gear.lip(defun grinfo ()
  2.    (setq c (getpoint "\n 齿轮中心: "))
  3.    (setq pc (getpoint "\n 节距圆: "))
  4.    (setq teeth (getint "\n 齿数: "))
  5.    (while (< teeth 14)
  6.        (setq teeth (getint "\n 必须至少14个齿: "))
  7.    )
  8.    (while (> teeth 50)
  9.        (setq teeth (getint "\n 必须不超过50个齿: "))
  10.    )
  11.    ;; (while(< teeth 14)(setq teeth(getint "\n 必须至少14个齿: ")))
  12.    ;;(while(> teeth 50)(setq teeth(getint "\n 必须不超过50个齿: ")))
  13. )(defun calgear ()
  14.    (setq d (* 2 (distance c pc)))
  15.    (setq pc (polar c 0 (/ d 2)))
  16.    (setq ang3 2.79248)
  17.    (setq ang5 (/ 360.000000 teeth))
  18.    (setq wang -0.785385)
  19.    (setq wang 20.785385)
  20.    (setq dp (/ teeth d))
  21.    (setq ht (/ 0.32 dp))
  22.    (setq adm (/ 1.0 dp))
  23.    (setq y (* (/ 2.257 dp) 1.0642))
  24. )(defun drawgear  ()
  25.    (command "PLINE"
  26.        (setq p (polar pc 0 adm))
  27.        "a"
  28.        "ce"
  29.        c
  30.        "l"
  31.        ht
  32.        "l"
  33.        (setq p (polar (getvar "lastpoint") ang3 y))
  34.        "a"
  35.        "ce"
  36.        c
  37.        "l"
  38.        ht
  39.        ""   )
  40.    (SETQ TOP (GETvar "LASTPOINT"))
  41.    (command "MIRROR"
  42.        "L"
  43.        ""
  44.        (setq p (polar pc 0 adm))
  45.        c
  46.        "n"
  47.    )
  48.    (command "ARRAY"
  49.        "w"
  50.        (POLAR TOP 4.712389 (* Y 1.5))
  51.        (polar TOP 0 Y)
  52.        ""
  53.        "c"
  54.        c
  55.        ang5
  56.        "-360"
  57.        "Y"
  58.    )
  59. )
  60. (defun C:GEAR ()
  61.    (grinfo)
  62.    (setq stdots (getvar "blipmode"))
  63.    (setq stech (getvar "cmdecho"))
  64.    (setvar "blipmode" 0)
  65.    (setvar "cmdecho" 0)
  66.    (calgear)
  67.    (drawgear)
  68.    (setvar "blipmode" stdots)
  69.    (setvar "cmdecho" stech)
  70. )
  71. (prompt "\n键入Gear换起命令: ")
 楼主| 发表于 2005-5-12 11:21:00 | 显示全部楼层
问题在哪呢?请楼上帮我继续修改!!同时希望各路LISP高手踊跃前来指正.
 楼主| 发表于 2005-5-12 14:37:00 | 显示全部楼层
我加载完后要怎样运行才会有齿轮出来呢


CAD命令行会提示键入GEAR换起命令,下一步该输什么啊,请高手不吝指点!!!大家见笑了,我还是一个初学者,往后还得各路高手多多关照!!
发表于 2005-5-12 15:38:00 | 显示全部楼层
最基础的问题.........


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-28 03:30 , Processed in 0.200678 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表