乐筑天下

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

[编程交流] 用于编辑的自动DCL创建者

[复制链接]

8

主题

56

帖子

48

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 11:21:21 | 显示全部楼层 |阅读模式
我发现这个lisp非常好用,除了我们的一些属性中有引号。
 
这是代码,我已经附上了dwg和jpg的我所说的错误。
 
  1. ;;;DCLATT.LSP
  2. ;This program is for demonstration and tutorial purposes only.
  3. ;This program, using Visual Lisp will extract attributes from
  4. ;a block and display them in a dialog box.
  5. ;The dialog box will be created "on the fly" with the relevant
  6. ;number of edit boxes ;to suit the number of attributes within
  7. ;the block.
  8. ;The new attribute data will then be retrieved from the dialog
  9. ;and the block updated.
  10. ;Written by Kenny Ramage - May 2002
  11. ;afralisp@mweb.com.na
  12. ;http://www.afralisp.com
  13. ;Usage :
  14. ;Load by typing (load "DCLATT") at the command prompt.
  15. ;Type DCLATT at the command prompt to run.
  16. ;Select any block containing attributes.
  17. ;Replace any of the values in the text boxes to updated
  18. ;the attributes.
  19. ;Dependencies : None that I know of.
  20. ;Not much in the way of error checking I'm afraid.
  21. ;Limitations : Will only edit a certain number of attributes.
  22. ;System dependent.
  23. ;I don't recommend more than 10.
  24. ;I've had up to 14 on my display.
  25. (prompt "\nType DCLATT to run.....")
  26. (defun c:dclatt ( / theblock thelist n taglist
  27. txtlist lg fname fn nu dcl_id l relist)
  28. ;load the visual lisp extensions
  29. (vl-load-com)
  30. ;get the entity and entity name
  31. (setq theblock (car (entsel)))
  32. ;convert to vl object
  33. (setq theblock (vlax-ename->vla-object theblock))
  34. ;check if it's a block
  35. (if (= (vlax-get-property theblock 'ObjectName)
  36. "AcDbBlockReference")
  37. ;if it is, do the following
  38. (progn
  39. ;check if it has attributes
  40. (if (= (vlax-get-property theblock
  41. 'HasAttributes) :vlax-true)
  42. ;if it has attributes, do the following
  43. (progn
  44. ;get the attributes
  45. (getatt theblock)
  46. ;create the dialog
  47. (create_dialog)
  48. ;run the dialog
  49. (run_the_dialog)
  50. ;update the attributes
  51. (upatt)
  52. );progn
  53. ;No attributes, inform the user
  54. (alert "This Block has No Attributes!!
  55. - Please try again.")
  56. );if
  57. );progn
  58. ;it's not a block, inform the user
  59. (alert "This is not a Block!! - Please try again.")
  60. );if
  61. (princ)
  62. );defun
  63. (defun getatt (enam)
  64. ;retrieve the attributes
  65. (setq thelist (vlax-safearray->list
  66. (variant-value
  67. (vla-getattributes enam))))
  68. ;process each attribute
  69. (foreach n thelist
  70. ;get the tag attribute data
  71. (setq taglist (cons (vla-get-tagString n) taglist)
  72. ;get the text attribute data
  73. txtlist (cons (vla-get-textString n) txtlist)
  74. ;how many attributes?
  75. lg (length taglist)
  76. );setq
  77. );foreach
  78. ;reverse the lists
  79. (setq taglist (reverse taglist)
  80. txtlist (reverse txtlist))
  81. );defun
  82. (defun create_dialog ()
  83. ;create a temp DCL file
  84. (setq fname (vl-filename-mktemp "dcl.dcl"))
  85. ;open it to write
  86. (setq fn (open fname "w"))
  87. ;write the dialog header coding
  88. (write-line "temp : dialog { label = "Edit Attributes";" fn)
  89. ;reset the incremental control number
  90. (setq nu 0)
  91. ;start the loop to create the edit boxes
  92. (repeat lg
  93. ;create the edit boxes
  94. (write-line ": edit_box {" fn)
  95. (setq l (strcat """ "eb" (itoa nu) """ ";"))
  96. (write-line (strcat "key = " l) fn)
  97. (setq l (nth nu taglist))
  98. (write-line (strcat "label = " """ l """ ";") fn)
  99. (setq l (nth nu txtlist))
  100. (write-line (strcat "value = " """ l """ ";") fn)
  101. (write-line "alignment = centered; edit_width = 20; }" fn)
  102. ;increment the counter
  103. (setq nu (1+ nu))
  104. );repeat
  105. ;ok and cancel button
  106. (write-line "ok_only; }" fn)
  107. ;close the temp DCL file
  108. (close fn)
  109. );defun
  110. (defun run_the_dialog ()
  111. ;load the dialog file and definition
  112. (setq dcl_id (load_dialog fname))
  113. (if (not (new_dialog "temp" dcl_id))
  114. (exit )
  115. );if
  116. (mode_tile "eb0" 2)
  117. ;if the OK button is selected
  118. (action_tile "accept" "(retatt)")
  119. ;start the dialog
  120. (start_dialog)
  121. ;unload the dialog
  122. (unload_dialog dcl_id)
  123. ;delete the temp DCL file
  124. (vl-file-delete fname)
  125. );defun
  126. (defun retatt ()
  127. ;reset the increment counter
  128. (setq nu 0)
  129. start the loop
  130. (repeat lg
  131. ;retrieve the tile value
  132. (setq l (get_tile (strcat "eb" (itoa nu))))
  133. ;add it to the list
  134. (setq relist (cons l relist))
  135. ;increment the counter
  136. (setq nu (1+ nu))
  137. );repeat
  138. (setq relist (reverse relist))
  139. ;close the dialog
  140. (done_dialog)
  141. );defun
  142. (defun upatt ()
  143. ;reset the increment counter
  144. (setq nu 0)
  145. ;start the loop
  146. (repeat lg
  147. ;update the attribute
  148. (vla-put-textstring (nth nu thelist) (nth nu relist))
  149. ;increment the counter
  150. (setq nu (1+ nu))
  151. );repeat
  152. ;update the block
  153. (vla-update theblock)
  154. );defun
  155. ;clean loading
  156. (princ)
  157. ;End of ATTDCL.LSP

122125vx32f34437141390.jpg
TTL2.DWG
122126ztxbk026vd0dewoj.jpg
dclatt。lsp
122128f5fvjwj5u02ovwjd.jpg
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:25:35 | 显示全部楼层
为什么不双击属性块?还是这个Lisp程序在做什么?
 
此外,如果有帮助的话,我不久前写了这篇文章:
ddatte2.lsp
回复

使用道具 举报

8

主题

56

帖子

48

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 11:31:05 | 显示全部楼层
是的,这很管用,但这让它变得更简单、更干净。会给你一个旋转。
回复

使用道具 举报

8

主题

56

帖子

48

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 11:32:57 | 显示全部楼层
完美的谢谢。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:36:10 | 显示全部楼层
不客气。
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:40:11 | 显示全部楼层
那普通的旧AttEdit(或ATE)呢?
 
此外,如果按住control键并双击属性(在较新版本中),它将打开一行在位属性编辑器。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:44:22 | 显示全部楼层
更简洁一点:
 
  1. ;; QuickEdit  ~  Lee Mac  ~  20.04.10
  2. (defun c:qe (/ e dc el c v )
  3. (while (and (setq e (car (nentsel))) (<= 0 (setq dc (load_dialog "ACAD"))))
  4.    (if (and (wcmatch (cdr (assoc 0 (setq el (entget e)))) "TEXT,ATTRIB")
  5.             (setq v  (cdr (assoc 1 el)) c v) (new_dialog "acad_txtedit" dc))
  6.      (progn
  7.        (set_tile "text_edit" v)
  8.        (action_tile "text_edit" "(setq v $value)")
  9.        (action_tile "cancel"    "(setq v c)")
  10.        (start_dialog)
  11.        (entupd (cdr (assoc -1 (entmod (subst (cons 1 v) (assoc 1 el) el)))))))
  12.    (unload_dialog dc))
  13. (princ))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:49:18 | 显示全部楼层
好悲痛。#$%#@%#$%的不同之处在于,相同的命令。。。。。
 
Thx Lee成功了。几个月来,我一直在断断续续地处理这个问题。我试过^c^c\u atte,也试过^c^c\u ddatte。
回复

使用道具 举报

8

主题

56

帖子

48

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-6 11:51:16 | 显示全部楼层
在向下拉菜单、双击操作等添加选项时,为了避免任何可能的问题,请始终使用命令名而不是命令别名。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:56:27 | 显示全部楼层
是的。只是要确定哪一个是别名。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 03:10 , Processed in 0.947020 second(s), 86 queries .

© 2020-2025 乐筑天下

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