3D Lisp例程和DCl帮助
你好当我试图引入一个对话框时,我在让代码正常工作方面遇到了一些麻烦。实际绘制密室的代码虽然没有我想要的那么完美,但现在我正试图把它打扮得漂漂亮亮。第一步是添加一个对话框,询问用户房间是圆形还是矩形。然后它将运行相应的命令。我有几个错误,主要是它告诉我,有太少的参数或它运行的错误告诉我,商会的定义无法找到。
实际的圆形和矩形命令很好地工作,除了它们仅适用于某些UCS之外,我正在尝试找出它们。我对这一切都很陌生,尤其是它的dcl方面,我复制并粘贴了它,然后试图更改它以适应我的命令,我试图理解,但我有点挣扎,所以任何帮助都将不胜感激。抱歉,如果它有点混乱,这是第一个Lisp程序,这不仅仅是一个简单的几行,我已经做了。
Lisp程序
(defun C:Circular()
(PROGN
(SETQ P6 (GETPOINT "\nPick the centre of the chamber: "))
(SETQ D (GETREAL "\nWhat is the external diameter of the chamber?: "))
(SETQ CH (GETREAL"\nWhat is the height of the chamber wall?: "))
(SETQ T1 (GETREAL "\nWhat is the thickness of the Wall?: "))
(SETQ BS1 (GETREAL "\nWhat is the thickness of the Base Slab?: "))
(SETQ RS1 (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
(COMMAND "LAYER" "N" "3D_CHAMBER_BASE" "S" "3D_CHAMBER_BASE" "C" "155" "" "");;;;Sets a new layer
;
;
;DRAW THE BASE SLAB
;
;
(SETQ P7 (LIST (CAR P6) (CADR P6) (CADDR P6)))
(COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws a cylinder for the base slab to the external dims of the wall
(SETQ ENTBASE1 (ENTLAST));;;;;Sets the previous object drawn to be called ENTBASE1 to make it easier for subtraction
(COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws the same cylinder again for it to be subtracted to create the base slab
;
;
;DRAW THE WALLS
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_WALL" "S" "3D_CHAMBER_WALL" "C" "155" "" "");;;;;Sets a new layer
(SETQ P8 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) BS1)))
(SETQ CWH (+ BS1 CH));;;;;Adds the base slab and height together to draw the walls
(COMMAND "CYLINDER" P8 "D" D CH);;;;;Draws a cylinder for the external walls
(SETQ ENT5 (ENTLAST));;;;;Sets the previous object drawn to be called ENT5 to make it easier for subtraction
(SETQ D1 (- D T1 T1));;;;;Sets the internal diameter to remove from the external cylinder
(COMMAND "CYLINDER" P8 "D" D1 CH);;;;;Draws a cylinder for the internal walls
(SETQ ENT6 (ENTLAST));;;;;Sets the previous object drawn to be called ENT6 to make it easier for subtraction
;
;
;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
;
;
(vlax-invoke
(vlax-ename->vla-object ent5)
'boolean
acSubtraction
(vlax-ename->vla-object entbase1)
)
(vlax-invoke
(vlax-ename->vla-object ent5)
'boolean
acSubtraction
(vlax-ename->vla-object ent6)
)
;
;
;DRAW THE ROOF SLAB NEXT
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_ROOF" "S" "3D_CHAMBER_ROOF" "C" "155" "" "");;;;Sets a new layer
(SETQ RSH1 (+ RS1 CH BS1));;;;;Sets the variable for the height of the total structure
(SETQ P9 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) CH BS1)))
(COMMAND "CYLINDER" P9 "D" D RS1);;;;;Draws a cylinder for the roof slab
(SETQ ENT7 (ENTLAST));;;;;Sets the previous object drawn to be called ENT7 to make it easier for subtraction
(COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws a cylinder for the base slab to the external dims of the wall
(SETQ ENT8 (ENTLAST));;;;;Sets the previous object drawn to be called ENT8 to make it easier for subtraction
(COMMAND "CYLINDER" P8 "D" D CH);;;;;Draws a cylinder for the external walls
(SETQ ENT9 (ENTLAST));;;;;Sets the previous object drawn to be called ENT9 to make it easier for subtraction
;
;
;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
;
;
(vlax-invoke
(vlax-ename->vla-object ent7)
'boolean
acSubtraction
(vlax-ename->vla-object ent8)
)
(vlax-invoke
(vlax-ename->vla-object ent7)
'boolean
acSubtraction
(vlax-ename->vla-object ent9)
)
;
;
;SET THE LAYER TO 0
;
;
(COMMAND "LAYER" "S" "0" "")
); PROGN
)
(defun C:Rectangular()
(PROGN
(SETVAR "CMDECHO" 0)
(SETVAR "DYNMODE" 0)
(SETQ P1 (GETPOINT "\nPick the lower left hand side of the chamber: "))
(SETQ W (GETREAL "\nWhat is the external width of the Wall?: "))
(SETQ L (GETREAL "\nWhat is the external length of the Wall?: "))
(SETQ H (GETREAL "\nWhat is the external height of the Wall?: "))
(SETQ T (GETREAL "\nWhat is the thickness of the Wall?: "))
(SETQ BS (GETREAL "\nWhat is the thickness of the Base Slab?: "))
(SETQ RS (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
(COMMAND "LAYER" "N" "3D_CHAMBER_BASE" "S" "3D_CHAMBER_BASE" "C" "155" "" "");;;;Sets a new layer
;
;
;DRAW THE BASE SLAB
;
;
(SETQ P2 (LIST (CAR P1) (CADR P1) (CADDR P1)))
(COMMAND "BOX" P2 "L" L W BS);;;;;Draws a box for the base slab to the external dims of the wall
(SETQ ENTBASE (ENTLAST));;;;;Sets the previous object drawn to be called ENTBASE to make it easier for subtraction
(COMMAND "BOX" P2 "L" L W BS);;;;;Draws the same box again for it to be subtracted to create the base slab
;
;
;DRAW THE WALLS
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_WALL" "S" "3D_CHAMBER_WALL" "C" "155" "" "");;;;;Sets a new layer
(SETQ P3 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) BS)))
(SETQ WH (+ BS H));;;;;Adds the base slab and height together to draw the walls
(COMMAND "BOX" P3 "L" L W WH);;;;;Draws a box for the external walls
(SETQ ENT1 (ENTLAST));;;;;Sets the previous object drawn to be called ENT1 to make it easier for subtraction
;
;
;;;;;Below sets the new variables to draw the internal of the wall
(SETQ PX1 (+ (CAR P1) T))
(SETQ PY1 (+ (CADR P1) T))
(SETQ P4 (LIST PX1 PY1 (+ (CADDR P1) BS)))
(SETQ L1 (- L T T))
(SETQ W1 (- W T T))
(COMMAND "BOX" P4 "L" L1 W1 WH);;;;;Draws a box to the internal dimensions of the wall
(SETQ ENT2 (ENTLAST));;;;;Sets the previous object drawn to be called ENT2 to make it easier for subtraction
;
;
;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
;
;
(vlax-invoke
(vlax-ename->vla-object ent1)
'boolean
acSubtraction
(vlax-ename->vla-object entbase)
)
(vlax-invoke
(vlax-ename->vla-object ent1)
'boolean
acSubtraction
(vlax-ename->vla-object ent2)
)
;
;
;DRAW THE ROOF SLAB NEXT
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_ROOF" "S" "3D_CHAMBER_ROOF" "C" "155" "" "");;;;Sets a new layer
(SETQ RSH (+ RS H BS));;;;;Sets the variable for the height of the total structure
(SETQ P5 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) H BS)))
(COMMAND "BOX" P5 "L" L W RSH);;;;;Draws a box for the roof slab
(SETQ ENTRS (ENTLAST));;;;;Sets the previous object drawn to be called ENTRS to make it easier for subtraction
(COMMAND "BOX" P2 "L" L W BS);;;;;Draws a box for the base slab to the external dims of the wall
(SETQ ENT3 (ENTLAST));;;;;Sets the previous object drawn to be called ENT3 to make it easier for subtraction
(COMMAND "BOX" P3 "L" L W WH);;;;;Draws a box for the external walls
(SETQ ENT4 (ENTLAST));;;;;Sets the previous object drawn to be called ENT4 to make it easier for subtraction
;
;
;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
;
;
(vlax-invoke
(vlax-ename->vla-object entrs)
'boolean
acSubtraction
(vlax-ename->vla-object ent3)
)
(vlax-invoke
(vlax-ename->vla-object entrs)
'boolean
acSubtraction
(vlax-ename->vla-object ent4)
)
;
;
;SET THE LAYER TO 0
;
;
(COMMAND "LAYER" "S" "0" "")
); PROGN
)
(defun doButton(a)
(cond
;;;
;;; - - - If the button selected was Circular then do this
;;;
((= a 1)(Circular))
;;;
;;; - - - If the button selected was Rectangular then do this
;;;
((= a 2)(Rectangular))
)
)
(defun C:CHAMBER()
(setq dcl_id (load_dialog "chamber1.dcl"))
(setq server_path "//C:\Users\earlesc\Documents\AutoCAD\_Customisation\3D Chamber Dialogue Box Test")
;;;- - - Else the file was loaded
(progn
;;;- - - Load the dialog definition inside the DCL file
(if(not(new_dialog "chamber1" dcl_id))
(progn
(alert " The chamber definition could not be found in the DCL file!")
(exit)
);;; End progn
(exit)
)
;;;- - - Else the definition was loaded
(progn
;;;- - - If an action event occurs, do this function
(action_tile "but1" "(doButton 1)")
(action_tile "but2" "(doButton 2)")
(action_tile "cancel" "(done_dialog)")
;;;- - -Display the dialog box
(start_dialog)
;;;- - - Unload the dialog box
(unload_dialog dcl_id)
)
)
)
;;;- - - Supress the last echo for a clean exit
(princ)
Dcl
chamber1 : dialog { //dialog name
label = "3D Chamber" ; //give it a label
: row {
: boxed_column {
: button {
key = "but1";
label = "Circular";
is_default = true;
}
: button {
key = "but2";
label = "Rectangular";
is_default = false;
}
}
}
} //end dialog
欢迎来到CadTutor。
除了一些错误外,(不要重新定义内置符号“t”),第一次尝试其实还不错。。。干得好
(defun C:Circular ( / P6 D CH T1 BS1 RS1 P7 ENTBASE1 P8 CWH ENT5 ENT6 ENT7 ENT8 ENT9 D1 RSH1 P9)
(PROGN
(SETQ P6 (GETPOINT "\nPick the centre of the chamber: "))
(SETQ
D (GETREAL "\nWhat is the external diameter of the chamber?: "
)
)
(SETQ CH (GETREAL "\nWhat is the height of the chamber wall?: "))
(SETQ T1 (GETREAL "\nWhat is the thickness of the Wall?: "))
(SETQ BS1 (GETREAL "\nWhat is the thickness of the Base Slab?: "))
(SETQ RS1 (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
(COMMAND "LAYER" "N" "3D_CHAMBER_BASE"
"S" "3D_CHAMBER_BASE" "C"
"155" "" ""
)
;;;;Sets a new layer
;
;
;DRAW THE BASE SLAB
;
;
(SETQ P7 (LIST (CAR P6) (CADR P6) (CADDR P6)))
(COMMAND "CYLINDER" P7 "D" D BS1)
;;;;;Draws a cylinder for the base slab to the external dims of the wall
(SETQ ENTBASE1 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENTBASE1 to make it easier for subtraction
(COMMAND "CYLINDER" P7 "D" D BS1)
;;;;;Draws the same cylinder again for it to be subtracted to create the base slab
;
;
;DRAW THE WALLS
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_WALL"
"S" "3D_CHAMBER_WALL" "C"
"155" "" ""
)
;;;;;Sets a new layer
(SETQ P8 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) BS1)))
(SETQ CWH (+ BS1 CH))
;;;;;Adds the base slab and height together to draw the walls
(COMMAND "CYLINDER" P8 "D" D CH)
;;;;;Draws a cylinder for the external walls
(SETQ ENT5 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT5 to make it easier for subtraction
(SETQ D1 (- D T1 T1))
;;;;;Sets the internal diameter to remove from the external cylinder
(COMMAND "CYLINDER" P8 "D" D1 CH)
;;;;;Draws a cylinder for the internal walls
(SETQ ENT6 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT6 to make it easier for subtraction
;
;
;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
;
;
(vlax-invoke
(vlax-ename->vla-object ent5)
'boolean
acSubtraction
(vlax-ename->vla-object entbase1)
)
(vlax-invoke
(vlax-ename->vla-object ent5)
'boolean
acSubtraction
(vlax-ename->vla-object ent6)
)
;
;
;DRAW THE ROOF SLAB NEXT
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_ROOF"
"S" "3D_CHAMBER_ROOF" "C"
"155" "" ""
)
;;;;Sets a new layer
(SETQ RSH1 (+ RS1 CH BS1))
;;;;;Sets the variable for the height of the total structure
(SETQ P9 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) CH BS1)))
(COMMAND "CYLINDER" P9 "D" D RS1)
;;;;;Draws a cylinder for the roof slab
(SETQ ENT7 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT7 to make it easier for subtraction
(COMMAND "CYLINDER" P7 "D" D BS1)
;;;;;Draws a cylinder for the base slab to the external dims of the wall
(SETQ ENT8 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT8 to make it easier for subtraction
(COMMAND "CYLINDER" P8 "D" D CH)
;;;;;Draws a cylinder for the external walls
(SETQ ENT9 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT9 to make it easier for subtraction
;
;
;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
;
;
(vlax-invoke
(vlax-ename->vla-object ent7)
'boolean
acSubtraction
(vlax-ename->vla-object ent8)
)
(vlax-invoke
(vlax-ename->vla-object ent7)
'boolean
acSubtraction
(vlax-ename->vla-object ent9)
)
;
;
;SET THE LAYER TO 0
;
;
(COMMAND "LAYER" "S" "0" "")
) ; PROGN
)
(defun C:Rectangular ( / P1 P2 P3 W L H Tn BS RS ENTBASE WH ENT1 ENT2 PX1 PY1 P4 L1 W1 RSH P5 ENTRS ENT3 ENT4)
(PROGN
(SETVAR "CMDECHO" 0)
(SETVAR "DYNMODE" 0)
(SETQ
P1 (GETPOINT "\nPick the lower left hand side of the chamber: "
)
)
(SETQ W (GETREAL "\nWhat is the external width of the Wall?: "))
(SETQ L (GETREAL "\nWhat is the external length of the Wall?: "))
(SETQ H (GETREAL "\nWhat is the external height of the Wall?: "))
(SETQ Tn (GETREAL "\nWhat is the thickness of the Wall?: "))
;******************* dont redefine T
(SETQ BS (GETREAL "\nWhat is the thickness of the Base Slab?: "))
(SETQ RS (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
(COMMAND "LAYER" "N" "3D_CHAMBER_BASE"
"S" "3D_CHAMBER_BASE" "C"
"155" "" ""
)
;;;;Sets a new layer
;
;
;DRAW THE BASE SLAB
;
;
(SETQ P2 (LIST (CAR P1) (CADR P1) (CADDR P1)))
(COMMAND "BOX" P2 "L" L W BS)
;;;;;Draws a box for the base slab to the external dims of the wall
(SETQ ENTBASE (ENTLAST))
;;;;;Sets the previous object drawn to be called ENTBASE to make it easier for subtraction
(COMMAND "BOX" P2 "L" L W BS)
;;;;;Draws the same box again for it to be subtracted to create the base slab
;
;
;DRAW THE WALLS
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_WALL"
"S" "3D_CHAMBER_WALL" "C"
"155" "" ""
)
;;;;;Sets a new layer
(SETQ P3 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) BS)))
(SETQ WH (+ BS H))
;;;;;Adds the base slab and height together to draw the walls
(COMMAND "BOX" P3 "L" L W WH)
;;;;;Draws a box for the external walls
(SETQ ENT1 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT1 to make it easier for subtraction
;
;
;;;;;Below sets the new variables to draw the internal of the wall
(SETQ PX1 (+ (CAR P1) Tn)) ;******************* Tn was T
(SETQ PY1 (+ (CADR P1) Tn))
(SETQ P4 (LIST PX1 PY1 (+ (CADDR P1) BS)))
(SETQ L1 (- L Tn Tn))
(SETQ W1 (- W Tn Tn))
(COMMAND "BOX" P4 "L" L1 W1 WH)
;;;;;Draws a box to the internal dimensions of the wall
(SETQ ENT2 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT2 to make it easier for subtraction
;
;
;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
;
;
(vlax-invoke
(vlax-ename->vla-object ent1)
'boolean
acSubtraction
(vlax-ename->vla-object entbase)
)
(vlax-invoke
(vlax-ename->vla-object ent1)
'boolean
acSubtraction
(vlax-ename->vla-object ent2)
)
;
;
;DRAW THE ROOF SLAB NEXT
;
;
(COMMAND "LAYER" "N" "3D_CHAMBER_ROOF"
"S" "3D_CHAMBER_ROOF" "C"
"155" "" ""
)
;;;;Sets a new layer
(SETQ RSH (+ RS H BS))
;;;;;Sets the variable for the height of the total structure
(SETQ P5 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) H BS)))
(COMMAND "BOX" P5 "L" L W RSH)
;;;;;Draws a box for the roof slab
(SETQ ENTRS (ENTLAST))
;;;;;Sets the previous object drawn to be called ENTRS to make it easier for subtraction
(COMMAND "BOX" P2 "L" L W BS)
;;;;;Draws a box for the base slab to the external dims of the wall
(SETQ ENT3 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT3 to make it easier for subtraction
(COMMAND "BOX" P3 "L" L W WH)
;;;;;Draws a box for the external walls
(SETQ ENT4 (ENTLAST))
;;;;;Sets the previous object drawn to be called ENT4 to make it easier for subtraction
;
;
;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
;
;
(vlax-invoke
(vlax-ename->vla-object entrs)
'boolean
acSubtraction
(vlax-ename->vla-object ent3)
)
(vlax-invoke
(vlax-ename->vla-object entrs)
'boolean
acSubtraction
(vlax-ename->vla-object ent4)
)
;
;
;SET THE LAYER TO 0
;
;
(COMMAND "LAYER" "S" "0" "")
) ; PROGN
)
(defun doButton (a)
(cond
;;;
;;; - - - If the button selected was Circular then do this
;;;
((= a 1) (c:Circular))
;;;
;;; - - - If the button selected was Rectangular then do this
;;;
((= a 2) (c:Rectangular))
)
)
(defun C:CHAMBER ( / dcl_id server_path drv)
(setq dcl_id (load_dialog "chamber1.dcl")
server_path "//C:\Users\earlesc\Documents\AutoCAD\_Customisation\3D Chamber Dialogue Box Test")
(if (not (new_dialog "chamber1" dcl_id))
(progn (alert "The chamber definition could not be found in the DCL file!")(exit))
(progn
;;;- - - If an action event occurs, do this function
(action_tile "but1" "(done_dialog 1)")
(action_tile "but2" "(done_dialog 2)")
(action_tile "cancel" "(done_dialog)")
;;;- - -Display the dialog box
(setq drv (start_dialog))
;;;- - - Unload the dialog box
(unload_dialog dcl_id)
(cond
((= drv 1)(doButton 1))
((= drv 2)(doButton 2))
)
)
)
;;;- - - Supress the last echo for a clean exit
(princ)
)
Rlx级 有几件事很突出。
在do按钮例程中,首先要调用
((= a 1)(Circular))....
((= a 2)(Rectangular))
但是你的例程被定义为c:圆形和c:矩形。去掉两个defuns中的“c:”。c:用于使其成为命令。
接下来,您是否要创建dcl进行练习?如果你是,那是一件事,但是只有两个选项的dcl弹出菜单似乎让你的代码过于复杂了。作为一个用户,我宁愿只按照命令行上的提示操作。看看格特沃德。
最后,我知道你说过你对用代码写作相当陌生,但为了其他程序员阅读你的代码。不要全部使用大写字母!
Rlx,
我相信你的意思是
(cond
((= drv 1)(doButton 1))
((= drv 2)(doButton 2))
)
哎呀。。。。 第一名(为什么?
你问我发了5个getreals。lsp对于这种情况,它可以扩展到5。代码用于自动创建的dcl中的1、2和3个问题。这只是一个复制粘贴3,使4,然后使5的情况。
GETVALS。lsp
; to call a 4 line getvals
(if (not AH:getval4) (load "getvals"))
(ah:getval4 "Height of the chamber wall?: " 6 4 "Thickness of the Wall?: " 6 4 "Thickness of the Base Slab?: " 6 4 "Thickness of the Roof Slab?: " 6 4)
(SETQ CH (atof val1)
T1 (atof val2)
BS1 (atof val3)
RS1 (atof val4)
)
谢谢大家,Rlx,我能问一下为什么把变量p6 h等放在括号里,为什么用a,我只是好奇,因为代码的那部分工作得很好。不那样做是一种坏习惯吗。
Hippe013我的意图是开发对话框,这样命令行中就不会出现任何内容,我只是想先用一个简单的对话框进行测试,然后再向其中添加其他内容。用于圆形和矩形的命令一开始是单独的命令,因为当我开始时,它们在一起,我很难让它们工作,所以我把它们分开,这样对我来说更容易,这也是为什么它们被定义为命令,我把它们放回一起,起初我确实使用了get word,但我去掉了它,因为我试图使用对话框最终,如果我能弄明白,这一切将只是一个对话框。我将改变这一切,我不知道为什么我这么做,哈哈,这是在做我的头,我只是懒惰。
BIGAL说实话,我不知道为什么我会使用progn,因为我对这一点很陌生,我试图自学,所以我知道代码中的一切可能不是最有效的做事方式。我一直在网上看不同的例子等,这是一个我发现和开发它使用progn工作,所以我留在我的想法是没有必要改变一些东西,除非它打破了哈哈。最终我希望我能学会最好的做事方法,但我只是从lisp例程开始。
谢谢你们的帮助和评论。 嗨,厄尔齐,
把变量名放在括号里就是很好的houskeeping。如果不这样做,并且有两个程序使用相同的变量名,它们可能会相互咬合。这就是为什么要声明局部或全局变量。
就我个人而言,我认为您应该使用更长的变量名,以便您的程序更易于阅读。当你在做一个项目的时候,一切都在你的脑海里,但是如果你想在几个月后改变一些事情,你就很难理解你在做什么。
gr.Rlx 谢谢你的信息rlx,我将重新编写它,但去掉大写字母,我可能会像你说的那样在你的建议中更改变量,这对我来说很有意义,但我可能会忘记这一切,我可能还会再写一些注释,以提醒我什么时候发生了什么。
谢谢你的帮助。 如果运行getvals。lsp和更改输出目录可以看到dcl代码,因为它有3个选项1框、2框或3框。这可能会帮助您了解一些DCL示例。
;(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(setq fo (open (setq fname C"\\acadtemp\\ddgetval.dcl""w")))
另一个建议是在代码中重复创建层时,将“层新建”设置为defun。您可以将其放入一个小defuns库中,这些defuns通常在启动时使用并加载。另一种方法是一次性使用所有层(setvar’clayer“3D\u CHAMBER\u ROOF”)
(defun newlayer (layname COL ) ; suggest add linetype also
(COMMAND "-LAYER" "N" layname "S" layname "C" col"" "")
)
(newlayer "3D_CHAMBER_ROOF""155")
页:
[1]
2