乐筑天下

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

[编程交流] 拿透镜有困难

[复制链接]
BCL

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:09:34 | 显示全部楼层 |阅读模式
您好,我有一个lisp程序,它使用DCL文件将自定义数据附加到实体。一切正常,但我试图让“长度”字段返回实体的实际长度,而不是手动输入。我并没有试图用这些数据来处理行长度,我只是想要实际值。任何帮助都会很好,我只是不确定我应该研究什么功能。
 
这是代码,它是来自AfraLISP的经过大量修改的代码,它工作得很好,但我也在尝试添加此功能
 
 
  1. (defun c:ENDT ( / )
  2. ;define function
  3. (setvar "cmdecho" 0)
  4. ;switch off command echo
  5. (prompt "\nSelect the entity to Modify data : ")
  6. ;prompt the user       
  7.        
  8. (setq e (entget (car (entsel)) '("AFRALISP")))
  9. ;get the associative code list
  10. (setq e1 (assoc -3 e))
  11. ;get the xdata
  12. (if (not e1)
  13. ;if there is no exdata
  14. (progn
  15. ;do the following
  16. (if (not (tblsearch "APPID" "AFRALISP"))
  17. ;check if the application has been registered
  18.        
  19.         (regapp "AFRALISP")
  20.         ;if not, register it
  21. );if
  22.         (setq e1 '(( -3 ("AFRALISP"
  23.                   (1000 . " ")
  24.                   (1000 . " ")
  25.                   (1000 . " ")
  26.                   (1000 . " ")
  27.                   (1000 . " ")
  28.                   (1000 . " ")
  29.                   (1000 . " ")
  30.                   (1000 . " ")
  31.                   (1000 . " ")
  32.                   (1000 . " ")
  33.         ))))
  34.         ;create a default xdata list
  35.        
  36.         (setq e (append e e1))
  37.         ;append to to the main list
  38.         (entmod e)
  39.         ;modify the entity
  40.        
  41. );progn
  42. );if
  43. (setq e2 (assoc -3 e))
  44. ;get the code -3 list
  45. (setq e3 (car (cdr e2)))
  46. ;get the exdata list
  47. (setq PN (cdr (nth 1 e3)))
  48. ;get the partnumber index number
  49. (setq EV (cdr (nth 2 e3)))
  50. ;get the elevation index number
  51. (setq DS (cdr (nth 3 e3)))
  52. ;get the description index number
  53.         (setq LE (cdr (nth 4 e3)))
  54. ;get the Leading Angle index number
  55. (setq TR (cdr (nth 5 e3)))
  56. ;get the trainling Angle index number
  57. (setq FL (cdr (nth 6 e3)))
  58. ;get the floor index number
  59.         (setq TA (cdr (nth 7 e3)))
  60. ;get the tag index number
  61. (setq CO (cdr (nth 8 e3)))
  62. ;get the color index number
  63. (setq LN (cdr (nth 9 e3)))
  64. ;get the length index number
  65.         (setq QU (cdr (nth 10 e3)))
  66. ;get the quanity index number
  67. (setq userclick T)
  68. ;set flag
  69. (setq PN1 PartNumber)
  70. ;Part Number Entry       
  71. (setq EL1 Elevation)
  72. ;Elevation Value Entry
  73.         (setq DS1 Description)
  74. ;Description value entry
  75.         (setq LE1 Langle)
  76. ;Part leading angle entry       
  77. (setq TR1 Tangle)
  78. ;part trailing angle entry
  79.         (setq FL1 Floor)
  80. ;floor
  81.         (setq TA1 Tag)
  82. ;Tag       
  83. (setq CO1 Color)
  84. ;Color Value Entry
  85.         (setq LN1 PartLength)
  86. ;Length
  87.         (setq QU1 Quantity)
  88. ;Quantity       
  89. (setq dcl_id (load_dialog "newENDT.dcl"))
  90. ;load dialogue
  91. (if (not (new_dialog "ENDT" dcl_id)
  92. ;check for errors
  93.       );not
  94.      (exit)
  95.      ;if problem exit
  96. );if
  97. (set_tile "PN1" PN)
  98. ;initilise list box
  99. (set_tile "EV1" EV)
  100. ;initilise list box
  101. (set_tile "DS1" DS)
  102. ;initilise list box
  103. (set_tile "LE1" LE)
  104. ;initilise list box
  105. (set_tile "TR1" TR)
  106. ;initilise list box
  107. (set_tile "FL1" FL)
  108. ;initilise list box
  109. (set_tile "TA1" TA)
  110. ;initilise list box
  111. (set_tile "CO1" CO)
  112. ;initilise list box
  113. (set_tile "LN1" LN)
  114. ;initilise list box
  115. (set_tile "QU1" QU)
  116. ;initilise list box
  117. (start_list "PN1")
  118. ;start the list
  119. (mapcar 'add_list PartNumber)
  120. ;add the partnumber
  121. (start_list "EV1")
  122. ;start the list
  123. (mapcar 'add_list Elevation)
  124. ;add the elevation
  125. (start_list "DS1")
  126. ;start the list
  127. (mapcar 'add_list Description)
  128. ;add the description
  129. (start_list "LE1")
  130. ;start the list
  131. (mapcar 'add_list Langle)
  132. ;add the leading angle
  133. (start_list "TR1")
  134. ;start the trainling angle
  135. (mapcar 'add_list Tangle)
  136. ;add the trailing angle
  137. (start_list "FL1")
  138. ;start the floor
  139. ;(mapcar 'add_list Floor)
  140. ;add the floor
  141. (start_list "TA1")
  142. ;start the tag
  143. (mapcar 'add_list Tag)
  144. ;add the tag
  145. (start_list "CO1")
  146. ;start the color
  147. ;(mapcar 'add_list Color)
  148. ;add the colr
  149. (start_list "LN1")
  150. ;start the length
  151. ;(mapcar 'add_list PartLength)
  152. ;add the length
  153. (start_list "QU1")
  154. ;start the quantity
  155. ;(mapcar 'add_list Quantity)
  156. ;add the quantity
  157. (end_list)
  158. ;end the list
  159.    (action_tile "cancel"       
  160.    ;if cancel selected
  161.         "(done_dialog)
  162. ;end dialog
  163. (setq userclick nil)"
  164. ;set flag to nill
  165.    );action_tile
  166.    ;if cancel set flag to nil
  167. (action_tile "accept"       
  168. "(setq PN (get_tile "PN1"))
  169. (setq EV (get_tile "EV1"))
  170. (setq DS (get_tile "DS1"))
  171. (setq LE (get_tile "LE1"))
  172. (setq TR (get_tile "TR1"))
  173. (setq FL (get_tile "FL1"))
  174. (setq TA (get_tile "TA1"))
  175. (setq co (get_tile "CO1"))
  176. (setq LN (get_tile "LN1"))
  177. (setq QU (get_tile "QU1"))
  178.          
  179. (done_dialog)
  180. (setq userclick T)"
  181. ;set the flag to true
  182. );action tile
  183. (start_dialog)       
  184. ;start the dialogue
  185. (unload_dialog dcl_id)       
  186. ;unload the dialogue
  187.   (if userclick       
  188.   ;if OK has been selected
  189.    (progn
  190.    ;do the following
  191. (setq NPN (cons 1000 PN))
  192. ;construct a new part number  list
  193. (setq NEV (cons 1000 EV))
  194.        ;construct a new elevation list
  195. (setq NDS (cons 1000 DS))
  196. ;construct a new description list
  197.        (setq NLE (cons 1000 LE))
  198. ;construct a new leading angle  list
  199. (setq NTR (cons 1000 TR))
  200.        ;construct a new trailing angle list
  201. (setq NFL (cons 1000 FL))
  202. ;construct a new floor list
  203.               (setq NTA (cons 1000 TA))
  204. ;construct a new floor  list
  205. (setq NCO (cons 1000 CO))
  206.        ;construct a new color list
  207. (setq NLN (cons 1000 LN))
  208. ;construct a new length list
  209.        (setq NQU (cons 1000 QU))
  210. ;construct a new quantity list
  211.      
  212. (setq e4 (chnitem NPN 2 e3))
  213. ;change the Partnumber list
  214. (setq e5 (chnitem NEV 3 e4))
  215. ;change the elevation list
  216. (setq e6 (chnitem NDS 4 e5))
  217. ;change the Description list
  218.        (setq e7 (chnitem NLE 5 e6))
  219. ;change the leading list
  220. (setq e8 (chnitem NTR 6 e7))
  221. ;change the trailing list
  222. (setq e9 (chnitem NFL 7 e8))
  223. ;change the floor list
  224.        (setq e10 (chnitem NTA 8 e9))
  225. ;change the tag list
  226. (setq e11 (chnitem NCO 9 e10))
  227. ;change the color list
  228. (setq e12 (chnitem NLN 10 e11))
  229. ;change the length list
  230. (setq e13 (chnitem NQU 11 e12))
  231. ;change the quantity list
  232.      
  233. ;break
  234.      
  235. (setq e14 (subst e13 e3 e2))
  236. ;update list
  237. (setq e15 (subst e14 e2 e))
  238. ;update list
  239. (entmod e15)
  240. ;update the entity
  241.      
  242.    (setq PN (nth (atoi PN) PartNumber))
  243.    ;get the Part Number from the list
  244.    (setq EV (nth (atoi EV) Elevation))
  245.     ;get the elevation from list
  246.      
  247.    (setq DS (nth (atoi DS) Description))
  248.     ;get the Description from the list
  249.    (setq LE (nth (atoi LE) Langle))
  250.     ;get the leading from the list
  251.    (setq TR (nth (atoi TR) Tangle))
  252.     ;get the trailing from list
  253.      
  254.    (setq FL (nth (atoi FL) Floor))
  255.     ;get the floor from the list
  256.    (setq TA (nth (atoi TA) Tag))
  257.     ;get the tag from the list
  258.    (setq CO (nth (atoi CO) Color))
  259.     ;get the color from list
  260.      
  261.    (setq LN (nth (atoi LN) PartLength))
  262.     ;get the Length from the list
  263.    (setq QU (nth (atoi QU) Quantity))
  264.     ;get the Quantity from the list
  265.      
  266.    (alert (strcat "The Part Number is " PN "\n"
  267.     "The Elevation is " EV "\n"
  268.     "The Description is " DS "\n"
  269.     "The Leading Angle is " LE "\n"
  270.     "The Trailing Angle is " TR "\n"
  271.            "The Floor is " FL "\n"
  272.     "The Tag is " TA "\n"
  273.            "The Color is " CO "\n"
  274.     "The Length is " LN "\n"
  275.             "The Quanity is " QU)
  276.    
  277.     );alert
  278.    );end progn
  279.   );end if
  280. (princ)
  281. ;finish cleanly
  282. );end defun
  283. ;;This function replaces any element in a list with another element
  284. ;;It requires 3 parameters (chnitem value itemnumber list)
  285. (defun chnitem (value num lst)
  286.     (setq num (- num 1))
  287.     (setq tmplt (list nil))
  288.     (setq tmplt2 (list nil))
  289.     (setq counter 0)
  290.     (repeat  num
  291.          (setq tmplt (append tmplt (list (nth counter lst))))
  292.          (setq counter (+ counter 1))
  293.     )
  294.     (setq counter (+ counter 1))
  295.     (repeat (- (length lst) (+ num 1))
  296.          (setq tmplt2 (append tmplt2 (list (nth counter lst))))
  297.          (setq counter (+ counter 1))
  298.     )
  299.     (setq tmplt (cdr tmplt))
  300.     (setq tmplt2 (cdr tmplt2))
  301.     (setq lst (append tmplt (list value) tmplt2))
  302. )
  303. (
  304. princ)
  305. ;load cleanly

 
谢谢你的建议,
 
布瑞恩
 
附笔
如果我的意图不明确,我可以上传一段视频
 
这是我的DCL,这是我运行lisp程序时得到的
 
我想做的是让长度字段由实际长度填充
170937nf2dfcin2ff82h2t.png
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-8-20 23:32 , Processed in 0.973700 second(s), 58 queries .

© 2020-2025 乐筑天下

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