乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 101|回复: 12

[编程交流] 3D Lisp例程和DCl帮助

[复制链接]

5

主题

30

帖子

25

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 17:57:43 | 显示全部楼层 |阅读模式
你好
 
当我试图引入一个对话框时,我在让代码正常工作方面遇到了一些麻烦。实际绘制密室的代码虽然没有我想要的那么完美,但现在我正试图把它打扮得漂漂亮亮。第一步是添加一个对话框,询问用户房间是圆形还是矩形。然后它将运行相应的命令。我有几个错误,主要是它告诉我,有太少的参数或它运行的错误告诉我,商会的定义无法找到。
 
实际的圆形和矩形命令很好地工作,除了它们仅适用于某些UCS之外,我正在尝试找出它们。我对这一切都很陌生,尤其是它的dcl方面,我复制并粘贴了它,然后试图更改它以适应我的命令,我试图理解,但我有点挣扎,所以任何帮助都将不胜感激。抱歉,如果它有点混乱,这是第一个Lisp程序,这不仅仅是一个简单的几行,我已经做了。
 
Lisp程序
  1. (defun C:Circular()
  2. (PROGN
  3. (SETQ P6 (GETPOINT "\nPick the centre of the chamber: "))
  4. (SETQ D (GETREAL "\nWhat is the external diameter of the chamber?: "))
  5. (SETQ CH (GETREAL"\nWhat is the height of the chamber wall?: "))
  6. (SETQ T1 (GETREAL "\nWhat is the thickness of the Wall?: "))
  7. (SETQ BS1 (GETREAL "\nWhat is the thickness of the Base Slab?: "))
  8. (SETQ RS1 (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
  9. (COMMAND "LAYER" "N" "3D_CHAMBER_BASE" "S" "3D_CHAMBER_BASE" "C" "155" "" "");;;;Sets a new layer
  10. ;
  11. ;
  12. ;DRAW THE BASE SLAB
  13. ;
  14. ;       
  15. (SETQ P7 (LIST (CAR P6) (CADR P6) (CADDR P6)))
  16. (COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws a cylinder for the base slab to the external dims of the wall
  17. (SETQ ENTBASE1 (ENTLAST));;;;;Sets the previous object drawn to be called ENTBASE1 to make it easier for subtraction
  18. (COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws the same cylinder again for it to be subtracted to create the base slab
  19. ;
  20. ;
  21. ;DRAW THE WALLS
  22. ;
  23. ;
  24. (COMMAND "LAYER" "N" "3D_CHAMBER_WALL" "S" "3D_CHAMBER_WALL" "C" "155" "" "");;;;;Sets a new layer
  25. (SETQ P8 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) BS1)))
  26. (SETQ CWH (+ BS1 CH));;;;;Adds the base slab and height together to draw the walls
  27. (COMMAND "CYLINDER" P8 "D" D CH);;;;;Draws a cylinder for the external walls
  28. (SETQ ENT5 (ENTLAST));;;;;Sets the previous object drawn to be called ENT5 to make it easier for subtraction
  29. (SETQ D1 (- D T1 T1));;;;;Sets the internal diameter to remove from the external cylinder
  30. (COMMAND "CYLINDER" P8 "D" D1 CH);;;;;Draws a cylinder for the internal walls
  31. (SETQ ENT6 (ENTLAST));;;;;Sets the previous object drawn to be called ENT6 to make it easier for subtraction
  32. ;
  33. ;
  34. ;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
  35. ;
  36. ;
  37. (vlax-invoke
  38. (vlax-ename->vla-object ent5)
  39. 'boolean
  40. acSubtraction
  41. (vlax-ename->vla-object entbase1)
  42. )
  43. (vlax-invoke
  44. (vlax-ename->vla-object ent5)
  45. 'boolean
  46. acSubtraction
  47. (vlax-ename->vla-object ent6)
  48. )
  49. ;
  50. ;
  51. ;DRAW THE ROOF SLAB NEXT
  52. ;
  53. ;
  54. (COMMAND "LAYER" "N" "3D_CHAMBER_ROOF" "S" "3D_CHAMBER_ROOF" "C" "155" "" "");;;;Sets a new layer
  55. (SETQ RSH1 (+ RS1 CH BS1));;;;;Sets the variable for the height of the total structure
  56. (SETQ P9 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) CH BS1)))
  57. (COMMAND "CYLINDER" P9 "D" D RS1);;;;;Draws a cylinder for the roof slab
  58. (SETQ ENT7 (ENTLAST));;;;;Sets the previous object drawn to be called ENT7 to make it easier for subtraction
  59. (COMMAND "CYLINDER" P7 "D" D BS1);;;;;Draws a cylinder for the base slab to the external dims of the wall
  60. (SETQ ENT8 (ENTLAST));;;;;Sets the previous object drawn to be called ENT8 to make it easier for subtraction
  61. (COMMAND "CYLINDER" P8 "D" D CH);;;;;Draws a cylinder for the external walls
  62. (SETQ ENT9 (ENTLAST));;;;;Sets the previous object drawn to be called ENT9 to make it easier for subtraction
  63. ;
  64. ;
  65. ;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
  66. ;
  67. ;
  68. (vlax-invoke
  69. (vlax-ename->vla-object ent7)
  70. 'boolean
  71. acSubtraction
  72. (vlax-ename->vla-object ent8)
  73. )
  74. (vlax-invoke
  75. (vlax-ename->vla-object ent7)
  76. 'boolean
  77. acSubtraction
  78. (vlax-ename->vla-object ent9)
  79. )
  80. ;
  81. ;
  82. ;SET THE LAYER TO 0
  83. ;
  84. ;
  85. (COMMAND "LAYER" "S" "0" "")
  86. ); PROGN
  87. )
  88. (defun C:Rectangular()
  89. (PROGN
  90. (SETVAR "CMDECHO" 0)
  91. (SETVAR "DYNMODE" 0)
  92. (SETQ P1 (GETPOINT "\nPick the lower left hand side of the chamber: "))
  93. (SETQ W (GETREAL "\nWhat is the external width of the Wall?: "))
  94. (SETQ L (GETREAL "\nWhat is the external length of the Wall?: "))
  95. (SETQ H (GETREAL "\nWhat is the external height of the Wall?: "))
  96. (SETQ T (GETREAL "\nWhat is the thickness of the Wall?: "))
  97. (SETQ BS (GETREAL "\nWhat is the thickness of the Base Slab?: "))
  98. (SETQ RS (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
  99. (COMMAND "LAYER" "N" "3D_CHAMBER_BASE" "S" "3D_CHAMBER_BASE" "C" "155" "" "");;;;Sets a new layer
  100. ;
  101. ;
  102. ;DRAW THE BASE SLAB
  103. ;
  104. ;       
  105. (SETQ P2 (LIST (CAR P1) (CADR P1) (CADDR P1)))
  106. (COMMAND "BOX" P2 "L" L W BS);;;;;Draws a box for the base slab to the external dims of the wall
  107. (SETQ ENTBASE (ENTLAST));;;;;Sets the previous object drawn to be called ENTBASE to make it easier for subtraction
  108. (COMMAND "BOX" P2 "L" L W BS);;;;;Draws the same box again for it to be subtracted to create the base slab
  109. ;
  110. ;
  111. ;DRAW THE WALLS
  112. ;
  113. ;
  114. (COMMAND "LAYER" "N" "3D_CHAMBER_WALL" "S" "3D_CHAMBER_WALL" "C" "155" "" "");;;;;Sets a new layer
  115. (SETQ P3 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) BS)))
  116. (SETQ WH (+ BS H));;;;;Adds the base slab and height together to draw the walls
  117. (COMMAND "BOX" P3 "L" L W WH);;;;;Draws a box for the external walls
  118. (SETQ ENT1 (ENTLAST));;;;;Sets the previous object drawn to be called ENT1 to make it easier for subtraction
  119. ;
  120. ;
  121. ;;;;;Below sets the new variables to draw the internal of the wall
  122. (SETQ PX1 (+ (CAR P1) T))
  123. (SETQ PY1 (+ (CADR P1) T))
  124. (SETQ P4 (LIST PX1 PY1 (+ (CADDR P1) BS)))
  125. (SETQ L1 (- L T T))
  126. (SETQ W1 (- W T T))
  127. (COMMAND "BOX" P4 "L" L1 W1 WH);;;;;Draws a box to the internal dimensions of the wall
  128. (SETQ ENT2 (ENTLAST));;;;;Sets the previous object drawn to be called ENT2 to make it easier for subtraction
  129. ;
  130. ;
  131. ;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
  132. ;
  133. ;
  134. (vlax-invoke
  135. (vlax-ename->vla-object ent1)
  136. 'boolean
  137. acSubtraction
  138. (vlax-ename->vla-object entbase)
  139. )
  140. (vlax-invoke
  141. (vlax-ename->vla-object ent1)
  142. 'boolean
  143. acSubtraction
  144. (vlax-ename->vla-object ent2)
  145. )
  146. ;
  147. ;
  148. ;DRAW THE ROOF SLAB NEXT
  149. ;
  150. ;
  151. (COMMAND "LAYER" "N" "3D_CHAMBER_ROOF" "S" "3D_CHAMBER_ROOF" "C" "155" "" "");;;;Sets a new layer
  152. (SETQ RSH (+ RS H BS));;;;;Sets the variable for the height of the total structure
  153. (SETQ P5 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) H BS)))
  154. (COMMAND "BOX" P5 "L" L W RSH);;;;;Draws a box for the roof slab
  155. (SETQ ENTRS (ENTLAST));;;;;Sets the previous object drawn to be called ENTRS to make it easier for subtraction
  156. (COMMAND "BOX" P2 "L" L W BS);;;;;Draws a box for the base slab to the external dims of the wall
  157. (SETQ ENT3 (ENTLAST));;;;;Sets the previous object drawn to be called ENT3 to make it easier for subtraction
  158. (COMMAND "BOX" P3 "L" L W WH);;;;;Draws a box for the external walls
  159. (SETQ ENT4 (ENTLAST));;;;;Sets the previous object drawn to be called ENT4 to make it easier for subtraction
  160. ;
  161. ;
  162. ;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
  163. ;
  164. ;
  165. (vlax-invoke
  166. (vlax-ename->vla-object entrs)
  167. 'boolean
  168. acSubtraction
  169. (vlax-ename->vla-object ent3)
  170. )
  171. (vlax-invoke
  172. (vlax-ename->vla-object entrs)
  173. 'boolean
  174. acSubtraction
  175. (vlax-ename->vla-object ent4)
  176. )
  177. ;
  178. ;
  179. ;SET THE LAYER TO 0
  180. ;
  181. ;
  182. (COMMAND "LAYER" "S" "0" "")
  183. ); PROGN
  184. )
  185. (defun doButton(a)
  186. (cond
  187. ;;;
  188. ;;; - - - If the button selected was Circular then do this
  189. ;;;
  190.         ((= a 1)(Circular))
  191. ;;;
  192. ;;; - - - If the button selected was Rectangular then do this
  193. ;;;
  194.         ((= a 2)(Rectangular))
  195. )
  196. )
  197. (defun C:CHAMBER()
  198. (setq dcl_id (load_dialog "chamber1.dcl"))
  199. (setq server_path "//C:\Users\earlesc\Documents\AutoCAD\_Customisation\3D Chamber Dialogue Box Test")
  200. ;;;- - - Else the file was loaded
  201. (progn
  202.         ;;;- - - Load the dialog definition inside the DCL file
  203.         (if(not(new_dialog "chamber1" dcl_id))
  204.                 (progn
  205.                         (alert " The chamber definition could not be found in the DCL file!")
  206.                         (exit)
  207.                 );;; End progn
  208.         (exit)
  209. )
  210. ;;;- - - Else the definition was loaded
  211. (progn
  212.        
  213.         ;;;- - - If an action event occurs, do this function
  214.         (action_tile "but1" "(doButton 1)")
  215.         (action_tile "but2" "(doButton 2)")
  216.         (action_tile "cancel" "(done_dialog)")
  217.         ;;;- - -Display the dialog box
  218.         (start_dialog)
  219.         ;;;- - - Unload the dialog box
  220.         (unload_dialog dcl_id)
  221.         )
  222. )
  223. )
  224. ;;;- - - Supress the last echo for a clean exit
  225. (princ)

 
Dcl
  1. chamber1 : dialog {                                //dialog name
  2.      label = "3D Chamber" ;                //give it a label
  3. : row {
  4. : boxed_column {
  5.    : button {
  6.                key = "but1";
  7.                label = "Circular";
  8.                is_default = true;
  9.    }  
  10.    : button {  
  11.                key = "but2";
  12.                label = "Rectangular";
  13.                is_default = false;  
  14.    }  
  15. }  
  16. }
  17.     }                                                //end dialog
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:06:55 | 显示全部楼层
欢迎来到CadTutor。
 
除了一些错误外,(不要重新定义内置符号“t”),第一次尝试其实还不错。。。干得好
 
  1. (defun C:Circular [color=red]( / P6 D CH T1 BS1 RS1 P7 ENTBASE1 P8 CWH ENT5 ENT6 ENT7 ENT8 ENT9 D1 RSH1 P9)[/color]
  2. (PROGN
  3.    (SETQ P6 (GETPOINT "\nPick the centre of the chamber: "))
  4.    (SETQ
  5.      D    (GETREAL "\nWhat is the external diameter of the chamber?: "
  6.    )
  7.    )
  8.    (SETQ CH (GETREAL "\nWhat is the height of the chamber wall?: "))
  9.    (SETQ T1 (GETREAL "\nWhat is the thickness of the Wall?: "))
  10.    (SETQ BS1 (GETREAL "\nWhat is the thickness of the Base Slab?: "))
  11.    (SETQ RS1 (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
  12.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_BASE"
  13.         "S"       "3D_CHAMBER_BASE"           "C"
  14.         "155"       ""         ""
  15.        )
  16. ;;;;Sets a new layer
  17.                    ;
  18.                    ;
  19.                    ;DRAW THE BASE SLAB
  20.                    ;
  21.                    ;   
  22.    (SETQ P7 (LIST (CAR P6) (CADR P6) (CADDR P6)))
  23.    (COMMAND "CYLINDER" P7 "D" D BS1)
  24. ;;;;;Draws a cylinder for the base slab to the external dims of the wall
  25.    (SETQ ENTBASE1 (ENTLAST))
  26. ;;;;;Sets the previous object drawn to be called ENTBASE1 to make it easier for subtraction
  27.    (COMMAND "CYLINDER" P7 "D" D BS1)
  28. ;;;;;Draws the same cylinder again for it to be subtracted to create the base slab
  29.                    ;
  30.                    ;
  31.                    ;DRAW THE WALLS
  32.                    ;
  33.                    ;
  34.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_WALL"
  35.         "S"       "3D_CHAMBER_WALL"           "C"
  36.         "155"       ""         ""
  37.        )
  38. ;;;;;Sets a new layer
  39.    (SETQ P8 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) BS1)))
  40.    (SETQ CWH (+ BS1 CH))
  41. ;;;;;Adds the base slab and height together to draw the walls
  42.    (COMMAND "CYLINDER" P8 "D" D CH)
  43. ;;;;;Draws a cylinder for the external walls
  44.    (SETQ ENT5 (ENTLAST))
  45. ;;;;;Sets the previous object drawn to be called ENT5 to make it easier for subtraction
  46.    (SETQ D1 (- D T1 T1))
  47. ;;;;;Sets the internal diameter to remove from the external cylinder
  48.    (COMMAND "CYLINDER" P8 "D" D1 CH)
  49. ;;;;;Draws a cylinder for the internal walls
  50.    (SETQ ENT6 (ENTLAST))
  51. ;;;;;Sets the previous object drawn to be called ENT6 to make it easier for subtraction
  52.                    ;
  53.                    ;
  54.                    ;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
  55.                    ;
  56.                    ;
  57.    (vlax-invoke
  58.      (vlax-ename->vla-object ent5)
  59.      'boolean
  60.      acSubtraction
  61.      (vlax-ename->vla-object entbase1)
  62.    )
  63.    (vlax-invoke
  64.      (vlax-ename->vla-object ent5)
  65.      'boolean
  66.      acSubtraction
  67.      (vlax-ename->vla-object ent6)
  68.    )
  69.                    ;
  70.                    ;
  71.                    ;DRAW THE ROOF SLAB NEXT
  72.                    ;
  73.                    ;
  74.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_ROOF"
  75.         "S"       "3D_CHAMBER_ROOF"           "C"
  76.         "155"       ""         ""
  77.        )
  78. ;;;;Sets a new layer
  79.    (SETQ RSH1 (+ RS1 CH BS1))
  80. ;;;;;Sets the variable for the height of the total structure
  81.    (SETQ P9 (LIST (CAR P6) (CADR P6) (+ (CADDR P6) CH BS1)))
  82.    (COMMAND "CYLINDER" P9 "D" D RS1)
  83. ;;;;;Draws a cylinder for the roof slab
  84.    (SETQ ENT7 (ENTLAST))
  85. ;;;;;Sets the previous object drawn to be called ENT7 to make it easier for subtraction
  86.    (COMMAND "CYLINDER" P7 "D" D BS1)
  87. ;;;;;Draws a cylinder for the base slab to the external dims of the wall
  88.    (SETQ ENT8 (ENTLAST))
  89. ;;;;;Sets the previous object drawn to be called ENT8 to make it easier for subtraction
  90.    (COMMAND "CYLINDER" P8 "D" D CH)
  91. ;;;;;Draws a cylinder for the external walls
  92.    (SETQ ENT9 (ENTLAST))
  93. ;;;;;Sets the previous object drawn to be called ENT9 to make it easier for subtraction
  94.                    ;
  95.                    ;
  96.                    ;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
  97.                    ;
  98.                    ;
  99.    (vlax-invoke
  100.      (vlax-ename->vla-object ent7)
  101.      'boolean
  102.      acSubtraction
  103.      (vlax-ename->vla-object ent8)
  104.    )
  105.    (vlax-invoke
  106.      (vlax-ename->vla-object ent7)
  107.      'boolean
  108.      acSubtraction
  109.      (vlax-ename->vla-object ent9)
  110.    )
  111.                    ;
  112.                    ;
  113.                    ;SET THE LAYER TO 0
  114.                    ;
  115.                    ;
  116.    (COMMAND "LAYER" "S" "0" "")
  117. )                    ; PROGN
  118. )
  119. (defun C:Rectangular [color=red]( / P1 P2 P3 W L H Tn BS RS ENTBASE WH ENT1 ENT2 PX1 PY1 P4 L1 W1 RSH P5 ENTRS ENT3 ENT4)[/color]
  120. (PROGN
  121.    (SETVAR "CMDECHO" 0)
  122.    (SETVAR "DYNMODE" 0)
  123.    (SETQ
  124.      P1 (GETPOINT "\nPick the lower left hand side of the chamber: "
  125.     )
  126.    )
  127.    (SETQ W (GETREAL "\nWhat is the external width of the Wall?: "))
  128.    (SETQ L (GETREAL "\nWhat is the external length of the Wall?: "))
  129.    (SETQ H (GETREAL "\nWhat is the external height of the Wall?: "))
  130.    (SETQ Tn (GETREAL "\nWhat is the thickness of the Wall?: "))
  131.                    [color=red];******************* dont redefine T[/color]
  132.    (SETQ BS (GETREAL "\nWhat is the thickness of the Base Slab?: "))
  133.    (SETQ RS (GETREAL "\nWhat is the thickness of the Roof Slab?: "))
  134.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_BASE"
  135.         "S"       "3D_CHAMBER_BASE"           "C"
  136.         "155"       ""         ""
  137.        )
  138. ;;;;Sets a new layer
  139.                    ;
  140.                    ;
  141.                    ;DRAW THE BASE SLAB
  142.                    ;
  143.                    ;   
  144.    (SETQ P2 (LIST (CAR P1) (CADR P1) (CADDR P1)))
  145.    (COMMAND "BOX" P2 "L" L W BS)
  146. ;;;;;Draws a box for the base slab to the external dims of the wall
  147.    (SETQ ENTBASE (ENTLAST))
  148. ;;;;;Sets the previous object drawn to be called ENTBASE to make it easier for subtraction
  149.    (COMMAND "BOX" P2 "L" L W BS)
  150. ;;;;;Draws the same box again for it to be subtracted to create the base slab
  151.                    ;
  152.                    ;
  153.                    ;DRAW THE WALLS
  154.                    ;
  155.                    ;
  156.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_WALL"
  157.         "S"       "3D_CHAMBER_WALL"           "C"
  158.         "155"       ""         ""
  159.        )
  160. ;;;;;Sets a new layer
  161.    (SETQ P3 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) BS)))
  162.    (SETQ WH (+ BS H))
  163. ;;;;;Adds the base slab and height together to draw the walls
  164.    (COMMAND "BOX" P3 "L" L W WH)
  165. ;;;;;Draws a box for the external walls
  166.    (SETQ ENT1 (ENTLAST))
  167. ;;;;;Sets the previous object drawn to be called ENT1 to make it easier for subtraction
  168.                    ;
  169.                    ;
  170. ;;;;;Below sets the new variables to draw the internal of the wall
  171.    (SETQ PX1 (+ (CAR P1) Tn))        [color=red];******************* Tn was T [/color]
  172.    (SETQ PY1 (+ (CADR P1) Tn))
  173.    (SETQ P4 (LIST PX1 PY1 (+ (CADDR P1) BS)))
  174.    (SETQ L1 (- L Tn Tn))
  175.    (SETQ W1 (- W Tn Tn))
  176.    (COMMAND "BOX" P4 "L" L1 W1 WH)
  177. ;;;;;Draws a box to the internal dimensions of the wall
  178.    (SETQ ENT2 (ENTLAST))
  179. ;;;;;Sets the previous object drawn to be called ENT2 to make it easier for subtraction
  180.                    ;
  181.                    ;
  182.                    ;SUBTRACT THE INTERNAL FROM EXTERNAL AND THE BASE SLAB FROM THE WALL
  183.                    ;
  184.                    ;
  185.    (vlax-invoke
  186.      (vlax-ename->vla-object ent1)
  187.      'boolean
  188.      acSubtraction
  189.      (vlax-ename->vla-object entbase)
  190.    )
  191.    (vlax-invoke
  192.      (vlax-ename->vla-object ent1)
  193.      'boolean
  194.      acSubtraction
  195.      (vlax-ename->vla-object ent2)
  196.    )
  197.                    ;
  198.                    ;
  199.                    ;DRAW THE ROOF SLAB NEXT
  200.                    ;
  201.                    ;
  202.    (COMMAND "LAYER"       "N"         "3D_CHAMBER_ROOF"
  203.         "S"       "3D_CHAMBER_ROOF"           "C"
  204.         "155"       ""         ""
  205.        )
  206. ;;;;Sets a new layer
  207.    (SETQ RSH (+ RS H BS))
  208. ;;;;;Sets the variable for the height of the total structure
  209.    (SETQ P5 (LIST (CAR P1) (CADR P1) (+ (CADDR P1) H BS)))
  210.    (COMMAND "BOX" P5 "L" L W RSH)
  211. ;;;;;Draws a box for the roof slab
  212.    (SETQ ENTRS (ENTLAST))
  213. ;;;;;Sets the previous object drawn to be called ENTRS to make it easier for subtraction
  214.    (COMMAND "BOX" P2 "L" L W BS)
  215. ;;;;;Draws a box for the base slab to the external dims of the wall
  216.    (SETQ ENT3 (ENTLAST))
  217. ;;;;;Sets the previous object drawn to be called ENT3 to make it easier for subtraction
  218.    (COMMAND "BOX" P3 "L" L W WH)
  219. ;;;;;Draws a box for the external walls
  220.    (SETQ ENT4 (ENTLAST))
  221. ;;;;;Sets the previous object drawn to be called ENT4 to make it easier for subtraction
  222.                    ;
  223.                    ;
  224.                    ;SUBTRACT THE WALLS AND THE BASE SLAB FROM THE ROOF SLAB
  225.                    ;
  226.                    ;
  227.    (vlax-invoke
  228.      (vlax-ename->vla-object entrs)
  229.      'boolean
  230.      acSubtraction
  231.      (vlax-ename->vla-object ent3)
  232.    )
  233.    (vlax-invoke
  234.      (vlax-ename->vla-object entrs)
  235.      'boolean
  236.      acSubtraction
  237.      (vlax-ename->vla-object ent4)
  238.    )
  239.                    ;
  240.                    ;
  241.                    ;SET THE LAYER TO 0
  242.                    ;
  243.                    ;
  244.    (COMMAND "LAYER" "S" "0" "")
  245. )                    ; PROGN
  246. )
  247. (defun doButton    (a)
  248. (cond
  249. ;;;
  250. ;;; - - - If the button selected was Circular then do this
  251. ;;;
  252.    ((= a 1) [color=red](c:Circular)[/color])
  253. ;;;
  254. ;;; - - - If the button selected was Rectangular then do this
  255. ;;;
  256.    ((= a 2) [color=red](c:Rectangular)[/color])
  257. )
  258. )
  259. (defun C:CHAMBER [color=red]( / dcl_id server_path drv)[/color]
  260. (setq dcl_id (load_dialog "chamber1.dcl")
  261.    server_path "//C:\Users\earlesc\Documents\AutoCAD\_Customisation\3D Chamber Dialogue Box Test")
  262. [color=red](if (not (new_dialog "chamber1" dcl_id))
  263.    (progn (alert "The chamber definition could not be found in the DCL file!")(exit))
  264.    (progn
  265.      ;;;- - - If an action event occurs, do this function
  266.      (action_tile "but1" "(done_dialog 1)")
  267.      (action_tile "but2" "(done_dialog 2)")
  268.      (action_tile "cancel" "(done_dialog)")
  269.      ;;;- - -Display the dialog box
  270.      (setq drv (start_dialog))
  271.      ;;;- - - Unload the dialog box
  272.      (unload_dialog dcl_id)
  273.      (cond
  274.    ((= drv 1)(doButton 1))
  275.    ((= drv 2)(doButton 2))
  276.      )
  277.    )
  278. )[/color]
  279. ;;;- - - Supress the last echo for a clean exit
  280. (princ)
  281. )
Rlx级
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 18:09:26 | 显示全部楼层
有几件事很突出。
 
在do按钮例程中,首先要调用
 
  1. ((= a 1)(Circular))....
  2. ((= a 2)(Rectangular))

 
但是你的例程被定义为c:圆形和c:矩形。去掉两个defuns中的“c:”。c:用于使其成为命令。
 
接下来,您是否要创建dcl进行练习?如果你是,那是一件事,但是只有两个选项的dcl弹出菜单似乎让你的代码过于复杂了。作为一个用户,我宁愿只按照命令行上的提示操作。看看格特沃德。
 
最后,我知道你说过你对用代码写作相当陌生,但为了其他程序员阅读你的代码。不要全部使用大写字母!
回复

使用道具 举报

20

主题

338

帖子

323

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 18:17:28 | 显示全部楼层
 
Rlx,
 
我相信你的意思是
 
  1. (cond
  2. ((= drv 1)(doButton 1))
  3. ((= drv 2)(doButton 2))
  4. )
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:22:37 | 显示全部楼层
 
 
哎呀。。。。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:27:25 | 显示全部楼层
第一名(为什么?
 
你问我发了5个getreals。lsp对于这种情况,它可以扩展到5。代码用于自动创建的dcl中的1、2和3个问题。这只是一个复制粘贴3,使4,然后使5的情况。
 
GETVALS。lsp
  1. ; to call a 4 line getvals
  2. (if (not AH:getval4) (load "getvals"))
  3. (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)
  4. (SETQ CH (atof val1)
  5.    T1 (atof val2)
  6.    BS1 (atof val3)
  7.    RS1 (atof val4)
  8. )

185747iv2yyiii2qkyv898.png
回复

使用道具 举报

5

主题

30

帖子

25

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 18:31:54 | 显示全部楼层
谢谢大家,Rlx,我能问一下为什么把变量p6 h等放在括号里,为什么用a,我只是好奇,因为代码的那部分工作得很好。不那样做是一种坏习惯吗。
 
Hippe013我的意图是开发对话框,这样命令行中就不会出现任何内容,我只是想先用一个简单的对话框进行测试,然后再向其中添加其他内容。用于圆形和矩形的命令一开始是单独的命令,因为当我开始时,它们在一起,我很难让它们工作,所以我把它们分开,这样对我来说更容易,这也是为什么它们被定义为命令,我把它们放回一起,起初我确实使用了get word,但我去掉了它,因为我试图使用对话框最终,如果我能弄明白,这一切将只是一个对话框。我将改变这一切,我不知道为什么我这么做,哈哈,这是在做我的头,我只是懒惰。
 
BIGAL说实话,我不知道为什么我会使用progn,因为我对这一点很陌生,我试图自学,所以我知道代码中的一切可能不是最有效的做事方式。我一直在网上看不同的例子等,这是一个我发现和开发它使用progn工作,所以我留在我的想法是没有必要改变一些东西,除非它打破了哈哈。最终我希望我能学会最好的做事方法,但我只是从lisp例程开始。
 
谢谢你们的帮助和评论。
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:37:40 | 显示全部楼层
嗨,厄尔齐,
 
 
把变量名放在括号里就是很好的houskeeping。如果不这样做,并且有两个程序使用相同的变量名,它们可能会相互咬合。这就是为什么要声明局部或全局变量。
 
 
就我个人而言,我认为您应该使用更长的变量名,以便您的程序更易于阅读。当你在做一个项目的时候,一切都在你的脑海里,但是如果你想在几个月后改变一些事情,你就很难理解你在做什么。
 
 
gr.Rlx
回复

使用道具 举报

5

主题

30

帖子

25

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 18:41:26 | 显示全部楼层
谢谢你的信息rlx,我将重新编写它,但去掉大写字母,我可能会像你说的那样在你的建议中更改变量,这对我来说很有意义,但我可能会忘记这一切,我可能还会再写一些注释,以提醒我什么时候发生了什么。
谢谢你的帮助。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:43:42 | 显示全部楼层
如果运行getvals。lsp和更改输出目录可以看到dcl代码,因为它有3个选项1框、2框或3框。这可能会帮助您了解一些DCL示例。
 
  1. ;(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  2. (setq fo (open (setq fname C"\\acadtemp\\ddgetval.dcl"  "w")))

 
另一个建议是在代码中重复创建层时,将“层新建”设置为defun。您可以将其放入一个小defuns库中,这些defuns通常在启动时使用并加载。另一种方法是一次性使用所有层(setvar’clayer“3D\u CHAMBER\u ROOF”)
 
  1. (defun newlayer (layname COL ) ; suggest add linetype also
  2. (COMMAND "-LAYER" "N" layname "S" layname "C" col  "" "")
  3. )
  4. (newlayer "3D_CHAMBER_ROOF"  "155")
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 23:49 , Processed in 0.427628 second(s), 74 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表