乐筑天下

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

[编程交流] 需要EED/扩展数据方面的帮助

[复制链接]
BCL

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:10:32 | 显示全部楼层 |阅读模式
大家好,第一次海报。我是一名业余程序员和autoCAD新手。我试图在visualLISP中创建一个项目,但在EED/扩展数据方面遇到了问题。我希望能够选择一个实体(在我的情况下,99%的时间它将是一条直线)并向其添加自定义数据。它总是有相同数量的数据条目,9(我需要查看Xrecord吗?),但对于每个实体,实际数据将不同。
 
我发现一些代码实现了一些类似于我试图实现的东西,所以我一直将其用作模板。我对其进行了大量修改,但不断出现DXF错误-如果有人能告诉我如何使用编辑框而不是弹出列表来实现这一点(这是我的“模板”使用的)。我还注释了我有疑问的部分代码,它们也是正确的(作者就在下面)。
 
正如我所说,我不是autoCAD power用户,但有一些面向对象编程的经验-任何示例代码、文献或教程都将不胜感激。
 
 
非常感谢。
 
布莱恩·莱文斯
 
 
这是我当前的DCL文件-它最终将有9个字段,但首先要做的是。
 
171036orv1bikbhv0hizvk.png
 
这是我试图操纵的模板,以实现我想要的功能
(不是我的代码)
 
  1. (defun c:exbolt ( / )
  2. ;define function
  3. (setvar "cmdecho" 0)                              
  4. ;switch off command echo
  5. (prompt "\nSelect the Line to add data to : ")
  6. ;prompt the user
  7. (setq e (entget (car (entsel)) '("AFRALISP")))
  8. ;get the associative code list
  9. (setq e1 (assoc -3 e))                              ;what is the assoc doing?
  10. ;get the xdata
  11. (if (not e1)
  12. ;if there is no exdata
  13. (progn
  14. ;do the following
  15. (if (not (tblsearch "APPID" "AFRALISP"))
  16. ;check if the application has been registered
  17.        
  18.         (regapp "AFRALISP")
  19.         ;if not, register it
  20. );if
  21.         (setq e1 '(( -3 ("AFRALISP"                ;I'm not to sure exactly this code works
  22.                   (1000 . "3")                     ;I know that 1000 is the DXF reference and the -3 is in
  23.                   (1000 . "3")                     ;reference to the xdata
  24.                     (1000 . "3")
  25.         ))))
  26.         ;create a default xdata list
  27.        
  28.         (setq e (append e e1))
  29.         ;append to to the main list
  30.         (entmod e)
  31.         ;modify the entity
  32.        
  33. );progn
  34. );if
  35. (setq e2 (assoc -3 e))
  36. ;get the code -3 list
  37. (setq e3 (car (cdr e2)))
  38. ;get the exdata list
  39. (setq SIZ (cdr (nth 1 e3)))
  40. ;get the bolt size index number
  41. (setq SIZ1 (cdr (nth 2 e3)))
  42. ;get the bolt length index number
  43. (setq gr (cdr (nth 3 e3)))
  44. ;get the bolt grade
  45. (setq userclick T)
  46. ;set flag
  47. (setq NAMES '("M6" "M8" "M10" "M12" "M16" "M20" "M24" "M30" "M36"
  48.               ))
  49. ;create list of bolt sizes
  50. (setq LEN '("10" "15" "20" "25" "30" "35" "40" "45" "50" "55" "60"))
  51. ;create list of bolt lengths
  52. (setq dcl_id (load_dialog "exbolt.dcl"))
  53. ;load dialogue
  54. (if (not (new_dialog "exbolt" dcl_id)
  55. ;check for errors
  56.       );not
  57.      (exit)
  58.      ;if problem exit
  59. );if
  60. (set_tile "sel1" SIZ)
  61. ;initilise list box
  62. (set_tile "sel2" SIZ1)
  63. ;initilise list box
  64. (start_list "sel1")
  65. ;start the list
  66. (mapcar 'add_list NAMES)
  67. ;add the bolt size
  68. (end_list)
  69. ;end the list
  70. (start_list "sel2")
  71. ;start the list
  72. (mapcar 'add_list LEN)
  73. ;add the lengths
  74. (end_list)
  75. ;end the list
  76. (cond
  77. ;on condition
  78. ((= gr "4,6") (set_tile "rb1" "1"))
  79. ;if GR 4,6 switch on radio button rb1
  80. ((= gr "8,8") (set_tile "rb2" "1"))
  81. ;if GR 8,8 switch on radio button rb2
  82. ((= gr "HSFG") (set_tile "rb3" "1"))
  83. ;if GR HSFG switch on radio button rb3
  84. );end cond
  85. (action_tile "rb1"
  86. ;if radio button rb1 selected
  87.            "(setq gr "4,6")"
  88. ;set grade of bolt
  89. );action_tile
  90. (action_tile "rb2"
  91. ;if radio button rb2 selected
  92.            "(setq gr "8,8")"
  93. ;set grade of bolt
  94. );action_tile
  95. (action_tile "rb3"
  96. ;if radio button rb3 selected
  97.            "(setq gr "HSFG")"
  98. ;set grade of bolt
  99. );action_tile
  100.    (action_tile "cancel"       
  101.    ;if cancel selected
  102.         "(done_dialog)
  103. ;end dialog
  104. (setq userclick nil)"
  105. ;set flag to nill
  106.    );action_tile
  107.    ;if cancel set flag to nil
  108. (action_tile "accept"       
  109.                                                 ;why is this section in quotations?
  110. "(setq siz (get_tile "sel1"))           
  111. ;get the bolt size
  112. (setq siz1 (get_tile "sel2"))
  113. ;get the bolt length
  114. (done_dialog)
  115. ;end the dialog
  116. (setq userclick T)"
  117. ;set the flag to true
  118. );action tile
  119. (start_dialog)       
  120. ;start the dialogue
  121. (unload_dialog dcl_id)       
  122. ;unload the dialogue
  123.   (if userclick       
  124.   ;if OK has been selected
  125.    (progn
  126.    ;do the following
  127. (setq NSIZ (cons 1000 SIZ))                       
  128. ;construct a new bolt size list
  129. (setq NSIZ1 (cons 1000 SIZ1))
  130. ;construct a new bolt length list
  131. (setq NGR (cons 1000 gr))
  132. ;construct a new bolt grade list
  133. (setq e4 (chnitem NSIZ 2 e3))
  134. ;change the existing bolt size list
  135. (setq e5 (chnitem NSIZ1 3 e4))
  136. ;change the existing bolt length list
  137. (setq e6 (chnitem NGR 4 e5))
  138. ;change the existing bolt grade list
  139. (setq e7 (subst e6 e3 e2))
  140. ;update list
  141. (setq e8 (subst e7 e2 e))
  142. ;update list
  143. (entmod e8)
  144. ;update the entity
  145.     (setq SIZ (nth (atoi SIZ) NAMES))
  146.     ;get the size of the bolt from the list
  147.     (setq SIZ1 (nth (atoi SIZ1) LEN))
  148.     ;get the length of the bolt from the list
  149.     (alert (strcat "The size of bolt is " SIZ "\n"
  150.     "The length of bolt is " SIZ1 "\n"
  151.     "The grade of bolt is " GR)
  152.     );alert
  153.    );end progn
  154.   );end if
  155. (princ)
  156. ;finish cleanly
  157. );end defun
  158. ;;This function replaces any element in a list with another element
  159. ;;It requires 3 parameters (chnitem value itemnumber list)
  160. (defun chnitem (value num lst)                                  ;I understand what this codes urpose is
  161.     (setq num (- num 1))                                        ;but do not it is the most confusing to me
  162.     (setq tmplt (list nil))
  163.     (setq tmplt2 (list nil))
  164.     (setq counter 0)
  165.     (repeat  num
  166.          (setq tmplt (append tmplt (list (nth counter lst))))
  167.          (setq counter (+ counter 1))
  168.     )
  169.     (setq counter (+ counter 1))
  170.     (repeat (- (length lst) (+ num 1))
  171.          (setq tmplt2 (append tmplt2 (list (nth counter lst))))
  172.          (setq counter (+ counter 1))
  173.     )
  174.     (setq tmplt (cdr tmplt))
  175.     (setq tmplt2 (cdr tmplt2))
  176.     (setq lst (append tmplt (list value) tmplt2))
  177. )
  178. (princ)
  179. ;load cleanly
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:26:42 | 显示全部楼层
下面是Afralisp的扩展数据示例,它似乎是代码的起点
,您需要更改的唯一一行是(setq thedata’(-3(“AFRALISP”(1000。“Kenny很帅”)(1000。“And intelligent”()))))),您可以添加9个值,也可以将AFRALISP更改为您希望的xata的名称。
 
如果你想要一个简单的9行dcl,我还会看一个库例程。我家里有一个,可以根据需要生成尽可能多的条目,我稍后会发布。在编写dcl时,只需要在lisp中编写几行代码。最近有一些帖子说要将多条目dcl作为库例程。
 
  1. Another important thing to remember about Xdata is that you can have more than one of the same associative code.
  2. Let's attach some xdata to an entity in a drawing. Draw a line then type this:
  3. (regapp "AFRALISP")
  4. AutoLisp should return :
  5. "AFRALISP"
  6. You have now registered your external entity data name. This name is a unique identifier to your own extended entity data. Next we need to get the entity data list of the entity that we want to add exdata to. Type this :
  7. (setq oldlist (entget (car (entsel)))) ; SINGLE ENTITY
  8. AutoLisp should return something like this :
  9. Select object: ((-1 . <Entity name: 2100888>) (0 . "LINE") (5 . "271")
  10. (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 336.561 591.45 0.0)
  11. (11 672.362 497.304 0.0) (210 0.0 0.0 1.0))
  12. Now, let's create the exdata that we want to add to the entity :
  13. (setq thedata '((-3 ("AFRALISP" (1000 . "Kenny is handsome") (1000 . "And intelligent")))))
  14. Append it to the entity data list :
  15. (setq newlist (append oldlist thedata))
  16. Now, update the entity :
  17. (entmod newlist)
  18. We have now attached the xdata to the entity. To retrieve it we would type this :
  19. (setq elist (entget (car (entsel)) '("AFRALISP")))
  20. This would return the modified entity list. It should look something like this :
  21. Select object: ((-1 . <Entity name: 2100888>) (0 . "LINE") (5 . "271")
  22. (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 336.561 591.45 0.0)
  23. (11 672.362 497.304 0.0) (210 0.0 0.0 1.0) (-3 ("AFRALISP" (1000 . "Kenny is handsome")
  24. (1000 . "And intelligent"))))
  25. To retrieve the xdata we would type this :
  26. (setq exlist (assoc -3 elist))
  27. This gets the xdata list from the entity list.
  28. (-3 ("AFRALISP" (1000 . "Kenny is handsome") (1000 . "And intelligent")))
  29. To retrieve the xdata itself we would type this :
  30. (setq thexdata (car (cdr exlist)))
  31. Now, we should have this :
  32. ("AFRALISP" (1000 . "Kenny is handsome") (1000 . "And intelligent"))
  33. We now have an ordinary list. Because we created the xdata list, and we know in what order we created it, it's very simple to retrieve each individual part :
  34. (setq data1 (cdr (nth 1 thexdata)))
  35. (setq data2 (cdr (nth 2 thexdata)))
  36. This should return :
  37. "Kenny is handsome"
  38. "And intelligent"
回复

使用道具 举报

BCL

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:33:22 | 显示全部楼层
谢谢你,我也想看看你的图书馆日常工作-谢谢你的回复
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:38:38 | 显示全部楼层
这不是多少dcl,而是一个12或3条目,它可以扩展到9,但我会做不同的,因为我已经发布了。
 
  1. (if (not AH:getval3)(load "getvals3"))
  2. (setq default1 "1" default2 "2" default "xx")
  3. (ah:getval3 "Line 1" 5 4 default1 "Line2" 8 7 default2 "Line 3" 6 4 default)

 
  1. ; Input  Dialog box with variable title
  2. ; multiple lines of dcl input supported
  3. ; add extra lines if required by copying code defun
  4. ; By Alan H 2015
  5. (vl-load-com)
  6. ; 1 line dcl
  7. ; sample code (ah:getval1 "Line 1" 5 4 defualt)
  8. (defun AH:getval1 (title width limit def1 / fo fname)
  9. ; you can hard code a directory if you like for dcl file
  10. ;(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  11. (setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
  12. (write-line "ddgetval : dialog {" fo)
  13. (write-line " : row {" fo)
  14. (write-line ": edit_box {" fo)
  15. (write-line (strcat "    key = "  (chr 34) "key1" (chr 34) ";") fo)
  16. (write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
  17. ; these can be replaced with shorter value etc
  18. (write-line (strcat "     edit_width = " (rtos width 2 0) ";" ) fo)
  19. (write-line (strcat "     edit_limit = " (rtos limit 2 0) ";" ) fo)
  20. (write-line "   is_enabled = true;" fo)
  21. (write-line "    }" fo)
  22. (write-line "  }" fo)
  23. (write-line "ok_only;}" fo)
  24. (close fo)
  25. (setq dcl_id (load_dialog  fname))
  26. ; pt is a list 2 numbs -1 -1 centre ('(20 20))
  27. ;(not (new_dialog "test" dch "" *screenpoint*))
  28. (if (not (new_dialog "ddgetval" dcl_id))
  29. (exit))
  30. (set_tile "key1" (setq val1 def1))
  31. (action_tile "key1" "(setq val1 $value)")
  32. (mode_tile "key1" 3)
  33. (start_dialog)
  34. (done_dialog)
  35. (unload_dialog dcl_id)
  36. ; returns the value of val1 as a string
  37. (vl-file-delete fname)
  38. ) ; defungetval1
  39. ; 2 line dcl
  40. ; sample code (ah:getval2 "Line 1" 5 4 default1 "Line2" 8 7 default2)
  41. (defun AH:getval2 (title1 width1 limit1 def1 title2 width2 limit2 def2 / fo fname)
  42. ;(setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
  43. (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  44. (write-line "ddgetval2 : dialog {" fo)
  45. (write-line " : column {" fo)
  46. (write-line ": edit_box {" fo)
  47. (write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
  48. (write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
  49. (write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
  50. (write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
  51. (write-line "   is_enabled = true ;" fo)
  52. (write-line "    }" fo)
  53. (write-line "spacer_1 ;" fo)
  54. (write-line ": edit_box {" fo)
  55. (write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
  56. (write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
  57. (write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
  58. (write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
  59. (write-line "   is_enabled = true ;" fo)
  60. (write-line "    }" fo)
  61. (write-line "    }" fo)
  62. (write-line "spacer_1 ;" fo)
  63. (write-line "ok_only;}" fo)
  64. (close fo)
  65. ; code part
  66. (setq dcl_id (load_dialog  fname))
  67. (if (not (new_dialog "ddgetval2" dcl_id))
  68. (exit))
  69. (mode_tile "key1" 3)
  70. (set_tile "key1" (setq val1 def1))
  71. (action_tile "key1" "(setq val1 $value)")
  72. (mode_tile "key2" 3)
  73. (set_tile "key2" (setq val2 def2))
  74. (action_tile "key2" "(setq val2 $value)")
  75. (start_dialog)
  76. (done_dialog)
  77. (unload_dialog dcl_id)
  78. ; returns the value of val1 and val2 as strings
  79. (vl-file-delete fname)
  80. ) ; defungetval2
  81. ; sample code (ah:getval3 "Line 1" 5 4 default1 "Line2" 8 7 default2 "Line 3" 6 4 "123")
  82. (defun AH:getval3 (title1 width1 limit1 def1 title2 width2 limit2 def2 title3 width3 limit3 def3 / fo fname)
  83. ;(setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
  84. (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
  85. (write-line "ddgetval3 : dialog {" fo)
  86. (write-line " : column {" fo)
  87. (write-line ": edit_box {" fo)
  88. (write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
  89. (write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
  90. (write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
  91. (write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
  92. (write-line "   is_enabled = true ;" fo)
  93. (write-line "    }" fo)
  94. (write-line "spacer_1 ;" fo)
  95. (write-line ": edit_box {" fo)
  96. (write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
  97. (write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
  98. (write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
  99. (write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
  100. (write-line "   is_enabled = true ;" fo)
  101. (write-line "    }" fo)
  102. (write-line "spacer_1 ;" fo)
  103. (write-line ": edit_box {" fo)
  104. (write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
  105. (write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
  106. (write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
  107. (write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
  108. (write-line "   is_enabled = true ;" fo)
  109. (write-line "    }" fo)
  110. (write-line "    }" fo)
  111. (write-line "spacer_1 ;" fo)
  112. (write-line "ok_only;}" fo)
  113. (close fo)
  114. ; code part
  115. (setq dcl_id (load_dialog  fname))
  116. (if (not (new_dialog "ddgetval3" dcl_id))
  117. (exit))
  118. (mode_tile "key1" 3)
  119. (set_tile "key1" (setq val1 def1))
  120. (action_tile "key1" "(setq val1 $value)")
  121. (mode_tile "key2" 3)
  122. (set_tile "key2" (setq val2 def2))
  123. (action_tile "key2" "(setq val2 $value)")
  124. (mode_tile "key3" 3)
  125. (set_tile "key3" (setq val3 def3))
  126. (action_tile "key3" "(setq val3 $value)")
  127. (start_dialog)
  128. (done_dialog)
  129. (unload_dialog dcl_id)
  130. ; returns the value of val1 val2 and val3 as strings
  131. (vl-file-delete fname)
  132. ) ; defungetval3
回复

使用道具 举报

BCL

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:48:22 | 显示全部楼层
谢谢,但要么我不理解你的代码(只看了大约3周的lisp)
 
这是我修改过的代码
 
  1. (defun c:ENDT ( / )
  2. ;define function
  3. (setvar "cmdecho" 0)
  4. ;switch off command echo
  5. (prompt "\nSelect the Hole to Add/Modify Xdata : ")
  6. ;prompt the user
  7. (setq e (entget (car (entsel)) '("AFRALISP")))
  8. ;get the associative code list
  9. (setq e1 (assoc -3 e))
  10. ;get the xdata
  11. (if (not e1)
  12. ;if there is no exdata
  13. (progn
  14. ;do the following
  15. (if (not (tblsearch "APPID" "AFRALISP"))
  16. ;check if the application has been registered
  17.        
  18.         (regapp "AFRALISP")
  19.         ;if not, register it
  20. );if
  21.         (setq e1 '(( -3 ("AFRALISP"
  22.                   (1000 . "Description")
  23.                   (1000 . "PartNumber")
  24.                   (1000 . "Elevation")
  25.                   
  26.         ))))
  27.         ;create a default xdata list
  28.        
  29.         (setq e (append e e1))
  30.         ;append to to the main list
  31.         (entmod e)
  32.         ;modify the entity
  33.        
  34. );progn
  35. );if
  36. (setq e2 (assoc -3 e))
  37. ;get the code -3 list
  38. (setq e3 (car (cdr e2)))
  39. ;get the exdata list
  40. (setq PN (cdr (nth 1 e3)))
  41. ;get the partnumber index number
  42. (setq EV (cdr (nth 2 e3)))
  43. ;get the elevation index number
  44. (setq DS (cdr (nth 3 e3)))
  45. ;get the description index number
  46. (setq userclick T)
  47. ;set flag
  48. (setq PartNumber '(" "))
  49. ;Part Number Entry       
  50. (setq Elevation '(" "))
  51. ;Elevation Value Entry
  52.         (setq Description '(" "))
  53. ;Description
  54. (setq dcl_id (load_dialog "ENDT.dcl"))
  55. ;load dialogue
  56. (if (not (new_dialog "ENDT" dcl_id)
  57. ;check for errors
  58.       );not
  59.      (exit)
  60.      ;if problem exit
  61. );if
  62. (set_tile "PN1" PN)
  63. ;initilise list box
  64. (set_tile "EV1" EV)
  65. ;initilise list box
  66. (set_tile "DS1" DS)
  67. ;initilise list box
  68. (start_list "PN1")
  69. ;start the list
  70. (mapcar 'add_list PartNumber)
  71. ;add the partnumber
  72. (end_list)
  73. ;end the list
  74. (start_list "EV1")
  75. ;start the list
  76. (mapcar 'add_list Elevation)
  77. ;add the elevation
  78. (start_list "DS1")
  79. ;start the list
  80. (mapcar 'add_list Description)
  81. ;add the description
  82. (end_list)
  83. ;end the list
  84. ;I commented out this next section because its not needed but I wanted to understand it later
  85. ;will delete it at completion - basically the origional template i used had radial buttons also
  86. ; (cond
  87. ;on condition
  88. ;        ((= gr "4,6") (set_tile "rb1" "1"))
  89. ;        ;if GR 4,6 switch on radio button rb1
  90. ;
  91. ;        ((= gr "8,8") (set_tile "rb2" "1"))
  92. ;        ;if GR 8,8 switch on radio button rb2
  93. ;
  94. ;        ((= gr "HSFG") (set_tile "rb3" "1"))
  95. ;        ;if GR HSFG switch on radio button rb3
  96. ;
  97. ; );end cond
  98. ;  (action_tile "rb1"
  99. ;  ;if radio button rb1 selected
  100. ;
  101. ;            "(setq gr "4,6")"
  102. ;        ;set grade of bolt
  103. ;
  104. ;  );action_tile
  105. ;
  106. ;  (action_tile "rb2"
  107. ;if radio button rb2 selected
  108. ;           "(setq gr "8,8")"
  109. ;set grade of bolt
  110. ;  );action_tile
  111. ;  (action_tile "rb3"
  112. ;if radio button rb3 selected
  113. ;            "(setq gr "HSFG")"
  114. ;set grade of bolt
  115. ; );action_tile
  116.    (action_tile "cancel"       
  117.    ;if cancel selected
  118.         "(done_dialog)
  119. ;end dialog
  120. (setq userclick nil)"
  121. ;set flag to nill
  122.    );action_tile
  123.    ;if cancel set flag to nil
  124. (action_tile "accept"       
  125. "(setq PN (get_tile "PN1"))
  126. (setq EV (get_tile "EV1"))
  127. (setq DS (get_tile "DS1"))
  128. (done_dialog)
  129. (setq userclick T)"
  130. ;set the flag to true
  131. );action tile
  132. (start_dialog)       
  133. ;start the dialogue
  134. (unload_dialog dcl_id)       
  135. ;unload the dialogue
  136.   (if userclick       
  137.   ;if OK has been selected
  138.    (progn
  139.    ;do the following
  140. (setq NPN (cons 1000 PN))
  141. ;construct a new part number  list
  142. (setq NEV (cons 1000 EV))
  143.        ;construct a new elevation list
  144. (setq NDS (cons 1000 DS))
  145. ;construct a new description list
  146. (setq e4 (chnitem NPN 2 e3))
  147. ;change the Partnumber list
  148. (setq e5 (chnitem NEV 3 e4))
  149. ;change the elevation list
  150. (setq e6 (chnitem NDS 4 e5))
  151. ;change the Description list
  152. (setq e7 (subst e6 e3 e2))
  153. ;update list
  154. (setq e8 (subst e7 e2 e))
  155. ;update list
  156. (entmod e8)
  157. ;update the entity
  158.     (setq PN (nth (atoi PN) PartNumber))
  159.     ;get the Part Number from the list
  160.    (setq EV (nth (atoi EV) Elevation))
  161.     ;get the elevation from list
  162.      
  163.    (setq DS (nth (atoi DS) Description))
  164.     ;get the Description from the list
  165.      (alert (strcat "The Part Number is " PN "\n"
  166.     "The Elevation is " EV "\n"
  167.     "The Description is " DS)
  168.     );alert
  169.    );end progn
  170.   );end if
  171. (princ)
  172. ;finish cleanly
  173. );end defun
  174. ;;This function replaces any element in a list with another element
  175. ;;It requires 3 parameters (chnitem value itemnumber list)
  176. (defun chnitem (value num lst)
  177.     (setq num (- num 1))
  178.     (setq tmplt (list nil))
  179.     (setq tmplt2 (list nil))
  180.     (setq counter 0)
  181.     (repeat  num
  182.          (setq tmplt (append tmplt (list (nth counter lst))))
  183.          (setq counter (+ counter 1))
  184.     )
  185.     (setq counter (+ counter 1))
  186.     (repeat (- (length lst) (+ num 1))
  187.          (setq tmplt2 (append tmplt2 (list (nth counter lst))))
  188.          (setq counter (+ counter 1))
  189.     )
  190.     (setq tmplt (cdr tmplt))
  191.     (setq tmplt2 (cdr tmplt2))
  192.     (setq lst (append tmplt (list value) tmplt2))
  193. )
  194. (
  195. princ)
  196. ;load cleanly

 
我总是会遇到这样的“坏DXF组:(-3(“AFRALISP”(1000)(1000)(1000))”错误-我想这与我需要使用编辑框这一事实有关,其中模板使用popup\u列表?
回复

使用道具 举报

BCL

2

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:54:14 | 显示全部楼层
仍然不能完全得到我想要的-如果有人可以看看上面的代码,也许可以批评它或帮助我一点,这将是伟大的。
 
谢谢-回到绘图板,
 
布瑞恩
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 17:04:05 | 显示全部楼层
这有点混淆了您的意图,因为您在谈论Visual LISP中的项目,但实际代码使用Vanilla LISP来操作某个ename的DXF列表中的扩展数据。
还有DCL编码,这会让你更加困惑——毕竟你提到你是“业余程序员和autocad新手”。
 
那么你的意图是什么
[列表]
  • A.使用vanilla lisp处理扩展数据(需要dxf列表操作)示例
  • B.使用visual lisp处理扩展数据(GetXdata/SetXdata方法)示例
  • C.将DCL与lisp结合使用-从这里开始。
    [/列表]
  • 回复

    使用道具 举报

    106

    主题

    1万

    帖子

    101

    银币

    顶梁支柱

    Rank: 50Rank: 50

    铜币
    1299
    发表于 2022-7-5 17:13:36 | 显示全部楼层
    像Grr一样,你的示例dcl是3行,但你的帖子说你想要9个项目,如果你发布一个dwg,比如说一行,这9个项目是文本,或者它们是其他对象属性或混合,试着给我们一张你想要的图片,用标签手工绘制dcl。
     
    你并不是在要求任何努力,对我们来说,重新开始比尝试修补你的代码更容易。
    回复

    使用道具 举报

    发表回复

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

    本版积分规则

    • 微信公众平台

    • 扫描访问手机版

    • 点击图片下载手机App

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

    GMT+8, 2025-3-13 19:41 , Processed in 0.486588 second(s), 71 queries .

    © 2020-2025 乐筑天下

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