我用您的建议和提示更新了lisp,方法如下:
- (DEFUN c:CPU ( / CNT DIAM INCH)
- (setq CNT (getpoint "\nselect circle center"));click the center of the circle
-
- (initget 1 "2 2.5 3 3.5 4 6 8 10 12 14 16 18 20")
- (setq INCH (getkword "\nSelect Diameter: [2 / 2.5 / 3 / 3.5 / 4 / 6 / 8 / 10 / 12 / 14 / 16 / 18 / 20]"))
- ;To do not write the real diameter number
- (setq DIAM (cond ((= INCH "2") 0.060325)
- ((= INCH "2.5") 0.073025)
- ((= INCH "3") 0.0889)
- ((= INCH "3.5") 0.1016)
- ((= INCH "4") 0.1143)
- ((= INCH "6") 0.1683)
- ((= INCH "8") 0.2191)
- ((= INCH "10") 0.2730)
- ((= INCH "12") 0.3238)
- ((= INCH "14") 0.3556)
- ((= INCH "16") 0.4064)
- ((= INCH "18") 0.4572)
- ((= INCH "20") 0.5080)
- );End conditional
- ) ;End setq
- (command "circle" "_non" CNT "D" DIAM);draw the circle
-
- (PRIN1)
- )
Lisp程序可以按照我的需要工作。之后,我想把圆放在与当前不同的层中(选择一个对象),然后返回到我的原始层。所以我写了这个新的lisp:
- (DEFUN c:CPU2 ( / CNT DIAM INCH P1)
- (setq P1 (entsel "\nSelect an object to create the circle in the same layer: "))
- (setq CNT (getpoint "\nselect circle center"));click the center of the circle
-
- (initget 1 "2 2.5 3 3.5 4 6 8 10 12 14 16 18 20")
- (setq INCH (getkword "\nSelect Diameter: [2 / 2.5 / 3 / 3.5 / 4 / 6 / 8 / 10 / 12 / 14 / 16 / 18 / 20]"))
- ;To do not write the real diameter number
- (setq DIAM (cond ((= INCH "2") 0.060325)
- ((= INCH "2.5") 0.073025)
- ((= INCH "3") 0.0889)
- ((= INCH "3.5") 0.1016)
- ((= INCH "4") 0.1143)
- ((= INCH "6") 0.1683)
- ((= INCH "8") 0.2191)
- ((= INCH "10") 0.2730)
- ((= INCH "12") 0.3238)
- ((= INCH "14") 0.3556)
- ((= INCH "16") 0.4064)
- ((= INCH "18") 0.4572)
- ((= INCH "20") 0.5080)
- );End conditional
- ) ;End setq DIAM
- (command "laymcur" P1; to move in other layer with a select
- (command "circle" "_non" CNT "D" DIAM);draw the circle
- (command "layerp"); return in the original layer
-
- (PRINC)
- )
像往常一样,我正在使用autocad的加载应用程序。该程序表示lisp已成功加载,但当我稍后在autocad中写入lisp名称时,该程序未找到lisp。
如果我写CPU,autocad会找到第一个lisp,但如果我写CPU2,它不会找到第二个lisp(它只找到第一个。我试图将其加载到另一台计算机中,但我遇到了相同的问题。是因为新的lisp不正确还是什么? |