乐筑天下

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

[编程交流] 在exis中插入“子”块

[复制链接]

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 10:48:36 | 显示全部楼层 |阅读模式
你好
 
过去几天,我一直在努力实现以下目标:
 
我有一个现有的块定义(blockname可以是:“ParentBlock1”)在这个块中插入另一个块(blockname可以是“ChildBlockOld”)。在ParenBlock1的定义中,我想用ChildBlockNew替换childblockcold。
 
我有一些使用旧AutoLisp的经验,但我认为用于实体操作的“经典”函数无法完成这项工作。VisualLisp(vlax和vla-stuff)和object-apporach是未知领域。因此,我在网上搜索灵感,找到了2个visual lisp例程,似乎就是为了这个目的而做的(多亏了最初发布这些例程的人)
ax:DeleteObjectFromBlock和
ax:AddObjectsToBlock
 
“Delete piece”工作正常,并从ParentBlock1中删除ChildBlockOld,但当我尝试添加ChildBlockNew时,会收到各种错误消息。
 
可能是我做错了什么,或者错过了显而易见的事情。
有谁熟悉这两个或类似的程序,将做的工作,可以引导我在正确的方向。
 
B、 R
卡斯滕
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:56:13 | 显示全部楼层
嗨,卡斯滕,
 
像这样的怎么样?
 
 
  1. ;;----------------=={ Add Objects to Block }==----------------;;
  2. ;;                                                            ;;
  3. ;;  Adds all objects in the provided SelectionSet to the      ;;
  4. ;;  definition of the specified block.                        ;;
  5. ;;------------------------------------------------------------;;
  6. ;;  Author: Lee McDonnell, June 2010                          ;;
  7. ;;                                                            ;;
  8. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  9. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  10. ;;------------------------------------------------------------;;
  11. ;;  Arguments:                                                ;;
  12. ;;  block - Entity name of reference insert                   ;;
  13. ;;  ss    - SelectionSet of objects to add to definition      ;;
  14. ;;------------------------------------------------------------;;
  15. (defun LM:AddObjectstoBlock ( block ss / ObjLst org doc vector )
  16. ;; © Lee Mac 2010
  17. (vl-load-com)
  18. (setq ObjLst (LM:ss->vla ss) org (vlax-3D-point '(0. 0. 0.)))
  19. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  20. (setq vector
  21.    (vlax-3D-point
  22.      (mapcar '- (cdr (assoc 10 (entget block)))
  23.        (cdr
  24.          (assoc 10
  25.            (entget
  26.              (tblobjname "BLOCK"
  27.                (cdr (assoc 2 (entget block)))
  28.              )
  29.            )
  30.          )
  31.        )
  32.      )
  33.    )
  34. )
  35. (mapcar '(lambda ( obj ) (vla-move obj vector org)) ObjLst)
  36. (vla-CopyObjects (vla-get-ActiveDocument (vlax-get-acad-object))
  37.    (LM:ObjectVariant ObjLst)
  38.    (vla-item (vla-get-Blocks doc)
  39.      (LM:GetBlockName (vlax-ename->vla-object block))
  40.    )
  41. )
  42. (LM:ApplyFootoSS (lambda ( x ) (entdel x)) ss)
  43. (vla-regen doc acAllViewports)
  44. )
  45. ;;------------------=={ Safearray Variant }==-----------------;;
  46. ;;                                                            ;;
  47. ;;  Creates a populated Safearray Variant of a specified      ;;
  48. ;;  data type                                                 ;;
  49. ;;------------------------------------------------------------;;
  50. ;;  Author: Lee McDonnell, June 2010                          ;;
  51. ;;                                                            ;;
  52. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  53. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  54. ;;------------------------------------------------------------;;
  55. ;;  Arguments:                                                ;;
  56. ;;  datatype - variant type enum (eg vlax-vbDouble)           ;;
  57. ;;  data     - list of static type data                       ;;
  58. ;;------------------------------------------------------------;;
  59. ;;  Returns:  VLA Variant Object of type specified            ;;
  60. ;;------------------------------------------------------------;;
  61.                         
  62. (defun LM:SafearrayVariant ( datatype data )
  63. ;; © Lee Mac 2010
  64. (vlax-make-variant
  65.    (vlax-safearray-fill
  66.      (vlax-make-safearray datatype
  67.        (cons 0 (1- (length data)))
  68.      )
  69.      data
  70.    )   
  71. )
  72. )
  73. ;;-------------------=={ Object Variant }==-------------------;;
  74. ;;                                                            ;;
  75. ;;  Creates a populated Object Variant                        ;;
  76. ;;------------------------------------------------------------;;
  77. ;;  Author: Lee McDonnell, June 2010                          ;;
  78. ;;                                                            ;;
  79. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  80. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  81. ;;------------------------------------------------------------;;
  82. ;;  Arguments:                                                ;;
  83. ;;  lst - list of VLA Objects to populate the Variant.        ;;
  84. ;;------------------------------------------------------------;;
  85. ;;  Returns:  VLA Object Variant                              ;;
  86. ;;------------------------------------------------------------;;
  87. (defun LM:ObjectVariant ( lst )
  88. ;; © Lee Mac 2010
  89. (LM:SafearrayVariant vlax-vbobject lst)
  90. )
  91. ;;-----------------=={ SelectionSet -> VLA }==----------------;;
  92. ;;                                                            ;;
  93. ;;  Converts a SelectionSet to a list of VLA Objects          ;;
  94. ;;------------------------------------------------------------;;
  95. ;;  Author: Lee McDonnell, June 2010                          ;;
  96. ;;                                                            ;;
  97. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  98. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  99. ;;------------------------------------------------------------;;
  100. ;;  Arguments:                                                ;;
  101. ;;  ss - Valid SelectionSet (Pickset)                         ;;
  102. ;;------------------------------------------------------------;;
  103. ;;  Returns:  List of VLA Objects                             ;;
  104. ;;------------------------------------------------------------;;
  105. (defun LM:ss->vla ( ss )
  106. ;; © Lee Mac 2010
  107. (if ss
  108.    (
  109.      (lambda ( i / e l )
  110.        (while (setq e (ssname ss (setq i (1+ i))))
  111.          (setq l (cons (vlax-ename->vla-object e) l))
  112.        )
  113.        l
  114.      )
  115.      -1
  116.    )
  117. )
  118. )
  119. ;;-------------------=={ Get Block Name }==-------------------;;
  120. ;;                                                            ;;
  121. ;;  Retrieves the Block Name as per the Block Definition      ;;
  122. ;;------------------------------------------------------------;;
  123. ;;  Author: Lee McDonnell, June 2010                          ;;
  124. ;;                                                            ;;
  125. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  126. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  127. ;;------------------------------------------------------------;;
  128. ;;  Arguments:                                                ;;
  129. ;;  obj - VLA Block Reference Object                          ;;
  130. ;;------------------------------------------------------------;;
  131. ;;  Returns:  Block Name [sTR]                                ;;
  132. ;;------------------------------------------------------------;;
  133. (defun LM:GetBlockName ( obj )
  134. (vlax-get-property obj
  135.    (if (vlax-property-available-p obj 'EffectiveName)
  136.      'EffectiveName 'Name
  137.    )
  138. )
  139. )
  140. ;;------------------=={ Apply Foo to SS }==-------------------;;
  141. ;;                                                            ;;
  142. ;;  Applies a function to every entity in a SelectionSet      ;;
  143. ;;------------------------------------------------------------;;
  144. ;;  Author: Lee McDonnell, June 2010                          ;;
  145. ;;                                                            ;;
  146. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  147. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  148. ;;------------------------------------------------------------;;
  149. ;;  Arguments:                                                ;;
  150. ;;  foo - a function taking one argument (an entity name)     ;;
  151. ;;  ss  - valid SelectionSet (pickset)                        ;;
  152. ;;------------------------------------------------------------;;
  153. ;;  Returns:  Last evaluation of function foo                 ;;
  154. ;;------------------------------------------------------------;;
  155. (defun LM:ApplyFootoSS ( foo ss )
  156. ;; © Lee Mac 2010
  157. (
  158.    (lambda ( i / e )
  159.      (while (setq e (ssname ss (setq i (1+ i)))) (foo e))
  160.    )
  161.    -1
  162. )
  163. )
  164. ;; Test Function.
  165. (defun c:test ( / ss ent )
  166. (if (and (setq ss  (ssget "_:L"))
  167.           (setq ent (car (entsel "\nSelect Block: ")))
  168.           (eq "INSERT" (cdr (assoc 0 (entget ent)))))
  169.    (LM:AddObjectstoBlock ent ss)
  170. )
  171. (princ)
  172. )
  173.    
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 10:59:56 | 显示全部楼层
李,你好,
 
谢谢你的回复。接下来的几天我会在路上,所以如果能解决我的问题,我需要花一些时间来探索和理解所附的代码。
 
当做
卡斯滕
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:09:15 | 显示全部楼层
没问题
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 11:11:00 | 显示全部楼层
李·麦克,
 
这很有效,非常感谢。
我加入了你的代码,这正是我想要的。
我还可以看到,我自己的尝试甚至都没有成功。
也许我可以用(命令“_BEdit”等)达到目标
但是,VLA方法似乎是一种更可靠的解决方案,并且具有更好的可移植性,因为BEDIT仅在ACAD 2006中引入。
 
你能帮我回答最后一个问题吗?上面的问题是序列中的最后一个步骤,其中还包括“复制”块定义,因此我有一个带有新块名的副本,这是我修改的一个(我仍然需要没有修改的旧块)。目前,我通过以下方式完成此操作:
(命令“_Bedit”ABNStack)
(命令“_Bsaveas”(strcat ABNStack“BC”))
(命令“_BClose”))
 
有没有一个更像“VLA”的东西也能做到这一点?
 
谢谢和问候
卡斯滕
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:16:25 | 显示全部楼层
这将使用ObjectDBX文档复制具有新名称的块,以将块定义复制到其中或从中复制。
 
http://www.cadtutor.net/forum/showthread.php?t=48840
 
哦,顺便说一句,我更新了我的代码以考虑所有视图和UCS:
 
  1. ;;----------------=={ Add Objects to Block }==----------------;;
  2. ;;                                                            ;;
  3. ;;  Adds all objects in the provided SelectionSet to the      ;;
  4. ;;  definition of the specified block.                        ;;
  5. ;;------------------------------------------------------------;;
  6. ;;  Author: Lee McDonnell, June 2010                          ;;
  7. ;;                                                            ;;
  8. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  9. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  10. ;;------------------------------------------------------------;;
  11. ;;  Arguments:                                                ;;
  12. ;;  block - Entity name of reference insert                   ;;
  13. ;;  ss    - SelectionSet of objects to add to definition      ;;
  14. ;;------------------------------------------------------------;;
  15. (defun LM:AddObjectstoBlock ( block ss / ObjLst doc Mat tMat vector )
  16. ;; © Lee Mac 2010
  17. (vl-load-com)
  18. (setq ObjLst (LM:ss->vla ss)
  19.           doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  20. (setq Mat (LM:Geom->Def (vlax-ename->vla-object block)))
  21. (setq vector
  22.    (mapcar '-
  23.      (cdr
  24.        (assoc 10
  25.          (tblsearch "BLOCK" (cdr (assoc 2 (entget block))))
  26.        )
  27.      )
  28.      (mxv Mat
  29.        (trans (cdr (assoc 10 (entget block)))
  30.          (cdr (assoc 210 (entget block))) 0 ; OCS->WCS
  31.        )
  32.      )
  33.    )
  34. )
  35. (setq tMat
  36.    (vlax-tmatrix
  37.      (append
  38.        (mapcar 'append mat (mapcar 'list vector)) '((0. 0. 0. 1.))
  39.      )
  40.    )
  41. )
  42. (mapcar '(lambda ( obj ) (vla-transformby obj tMat)) ObjLst)
  43. (vla-CopyObjects doc (LM:ObjectVariant ObjLst)
  44.    (vla-item (vla-get-Blocks doc)
  45.      (LM:GetBlockName (vlax-ename->vla-object block))
  46.    )
  47. )
  48. (LM:ApplyFootoSS (lambda ( x ) (entdel x)) ss)
  49. (vla-regen doc acAllViewports)
  50. )
  51. ;;-----------------=={ Remove From Block }==------------------;;
  52. ;;                                                            ;;
  53. ;;  Removes an Entity from a Block Definition                 ;;
  54. ;;------------------------------------------------------------;;
  55. ;;  Author: Lee McDonnell, June 2010                          ;;
  56. ;;                                                            ;;
  57. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  58. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  59. ;;------------------------------------------------------------;;
  60. ;;  Arguments:                                                ;;
  61. ;;  ent - Entity name of Object to Delete from Block [ENAME]  ;;
  62. ;;------------------------------------------------------------;;
  63. (defun LM:RemovefromBlock ( ent )
  64. ;; © Lee Mac 2010
  65. (vl-load-com)
  66. (vla-Delete (vlax-ename->vla-object ent))
  67. (vla-regen
  68.    (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports
  69. )
  70. )
  71. ;;------------------=={ Safearray Variant }==-----------------;;
  72. ;;                                                            ;;
  73. ;;  Creates a populated Safearray Variant of a specified      ;;
  74. ;;  data type                                                 ;;
  75. ;;------------------------------------------------------------;;
  76. ;;  Author: Lee McDonnell, June 2010                          ;;
  77. ;;                                                            ;;
  78. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  79. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  80. ;;------------------------------------------------------------;;
  81. ;;  Arguments:                                                ;;
  82. ;;  datatype - variant type enum (eg vlax-vbDouble)           ;;
  83. ;;  data     - list of static type data                       ;;
  84. ;;------------------------------------------------------------;;
  85. ;;  Returns:  VLA Variant Object of type specified            ;;
  86. ;;------------------------------------------------------------;;
  87.                         
  88. (defun LM:SafearrayVariant ( datatype data )
  89. ;; © Lee Mac 2010
  90. (vlax-make-variant
  91.    (vlax-safearray-fill
  92.      (vlax-make-safearray datatype
  93.        (cons 0 (1- (length data)))
  94.      )
  95.      data
  96.    )   
  97. )
  98. )
  99. ;;-------------------=={ Object Variant }==-------------------;;
  100. ;;                                                            ;;
  101. ;;  Creates a populated Object Variant                        ;;
  102. ;;------------------------------------------------------------;;
  103. ;;  Author: Lee McDonnell, June 2010                          ;;
  104. ;;                                                            ;;
  105. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  106. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  107. ;;------------------------------------------------------------;;
  108. ;;  Arguments:                                                ;;
  109. ;;  lst - list of VLA Objects to populate the Variant.        ;;
  110. ;;------------------------------------------------------------;;
  111. ;;  Returns:  VLA Object Variant                              ;;
  112. ;;------------------------------------------------------------;;
  113. (defun LM:ObjectVariant ( lst )
  114. ;; © Lee Mac 2010
  115. (LM:SafearrayVariant vlax-vbobject lst)
  116. )
  117. ;;-----------------=={ SelectionSet -> VLA }==----------------;;
  118. ;;                                                            ;;
  119. ;;  Converts a SelectionSet to a list of VLA Objects          ;;
  120. ;;------------------------------------------------------------;;
  121. ;;  Author: Lee McDonnell, June 2010                          ;;
  122. ;;                                                            ;;
  123. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  124. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  125. ;;------------------------------------------------------------;;
  126. ;;  Arguments:                                                ;;
  127. ;;  ss - Valid SelectionSet (Pickset)                         ;;
  128. ;;------------------------------------------------------------;;
  129. ;;  Returns:  List of VLA Objects                             ;;
  130. ;;------------------------------------------------------------;;
  131. (defun LM:ss->vla ( ss )
  132. ;; © Lee Mac 2010
  133. (if ss
  134.    (
  135.      (lambda ( i / e l )
  136.        (while (setq e (ssname ss (setq i (1+ i))))
  137.          (setq l (cons (vlax-ename->vla-object e) l))
  138.        )
  139.        l
  140.      )
  141.      -1
  142.    )
  143. )
  144. )
  145. ;;-------------------=={ Get Block Name }==-------------------;;
  146. ;;                                                            ;;
  147. ;;  Retrieves the Block Name as per the Block Definition      ;;
  148. ;;------------------------------------------------------------;;
  149. ;;  Author: Lee McDonnell, June 2010                          ;;
  150. ;;                                                            ;;
  151. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  152. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  153. ;;------------------------------------------------------------;;
  154. ;;  Arguments:                                                ;;
  155. ;;  obj - VLA Block Reference Object                          ;;
  156. ;;------------------------------------------------------------;;
  157. ;;  Returns:  Block Name [sTR]                                ;;
  158. ;;------------------------------------------------------------;;
  159. (defun LM:GetBlockName ( obj )
  160. (vlax-get-property obj
  161.    (if (vlax-property-available-p obj 'EffectiveName)
  162.      'EffectiveName 'Name
  163.    )
  164. )
  165. )
  166. ;;------------------=={ Apply Foo to SS }==-------------------;;
  167. ;;                                                            ;;
  168. ;;  Applies a function to every entity in a SelectionSet      ;;
  169. ;;------------------------------------------------------------;;
  170. ;;  Author: Lee McDonnell, June 2010                          ;;
  171. ;;                                                            ;;
  172. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  173. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  174. ;;------------------------------------------------------------;;
  175. ;;  Arguments:                                                ;;
  176. ;;  foo - a function taking one argument (an entity name)     ;;
  177. ;;  ss  - valid SelectionSet (pickset)                        ;;
  178. ;;------------------------------------------------------------;;
  179. ;;  Returns:  Last evaluation of function foo                 ;;
  180. ;;------------------------------------------------------------;;
  181. (defun LM:ApplyFootoSS ( foo ss )
  182. ;; © Lee Mac 2010
  183. (
  184.    (lambda ( i / e )
  185.      (while (setq e (ssname ss (setq i (1+ i)))) (foo e))
  186.    )
  187.    -1
  188. )
  189. )
  190. ;;---------------------=={ Geom->Def }==----------------------;;
  191. ;;                                                            ;;
  192. ;;  Returns the Transformation Matrix for transforming Block  ;;
  193. ;;  Geometry to the Block Definiton.                          ;;
  194. ;;------------------------------------------------------------;;
  195. ;;  Author: Lee McDonnell, June 2010                          ;;
  196. ;;                                                            ;;
  197. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  198. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  199. ;;------------------------------------------------------------;;
  200. ;;  Arguments:                                                ;;
  201. ;;  SourceBlock - VLA Block Reference Object                  ;;
  202. ;;------------------------------------------------------------;;
  203. ;;  Returns:  A 3x3 Transformation Matrix                     ;;
  204. ;;------------------------------------------------------------;;
  205. (defun LM:Geom->Def ( SourceBlock / norm ang x y z )
  206. ;; © Lee Mac  ~  11.06.10
  207. (vl-load-com)
  208. (setq norm (vlax-get SourceBlock 'Normal)
  209.         ang (- (vla-get-rotation SourceBlock)))
  210.      
  211. (mapcar 'set '(x y z)
  212.    (mapcar
  213.      '(lambda ( prop alt )
  214.         (/ 1.
  215.            (vlax-get-property SourceBlock
  216.              (if (vlax-property-available-p SourceBlock prop) prop alt)
  217.            )
  218.          )
  219.       )
  220.      '(XEffectiveScaleFactor YEffectiveScaleFactor ZEffectiveScaleFactor)
  221.      '(XScaleFactor          YScaleFactor          ZScaleFactor         )
  222.    )
  223. )
  224. (mxm
  225.    (list
  226.      (list x 0. 0.)
  227.      (list 0. y 0.)
  228.      (list 0. 0. z)
  229.    )
  230.    (mxm
  231.      (list
  232.        (list (cos ang) (sin (- ang)) 0.)
  233.        (list (sin ang) (cos ang)     0.)
  234.        (list     0.        0.        1.)
  235.      )
  236.      (mapcar '(lambda ( e ) (trans e norm 0 t)) ; OCS->WCS
  237.        '((1. 0. 0.) (0. 1. 0.) (0. 0. 1.))
  238.      )
  239.    )
  240. )
  241. )
  242. ;; Matrix x Vector  ~  Vladimir Nesterovsky
  243. (defun mxv ( m v )
  244. (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m))
  245. ;; Matrix x Matrix  ~  Vladimir Nesterovsky
  246. (defun mxm ( m q )
  247. (mapcar (function (lambda ( r ) (mxv (trp q) r))) m)
  248. )
  249. ;; Matrix Transpose  ~  Doug Wilson
  250. (defun trp ( m ) (apply 'mapcar (cons 'list m)))
  251. ;; -- Test Functions --
  252. (defun c:Add ( / *error* doc undo ss ent )
  253. (vl-load-com)
  254. ;; © Lee Mac 2010
  255. (defun *error* ( msg )
  256.    (and undo (vla-EndUndomark doc))
  257.    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  258.        (princ (strcat "\n** Error: " msg " **")))
  259.    (princ)
  260. )
  261. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  262. (if (and (setq ss  (ssget "_:L"))
  263.           (setq ent (car (entsel "\nSelect Block: ")))
  264.           (eq "INSERT" (cdr (assoc 0 (entget ent)))))
  265.    (progn
  266.      (setq undo (not (vla-StartUndoMark doc)))
  267.      (LM:AddObjectstoBlock ent ss)
  268.      (setq undo (vla-EndUndoMark doc))
  269.    )
  270. )
  271. (princ)
  272. )
  273. ;-------------------------------------------------------------
  274. (defun c:Remove ( / *error* doc undo ss )
  275. (vl-load-com)
  276. ;; © Lee Mac 2010
  277. (defun *error* ( msg )
  278.    (and undo (vla-EndUndomark doc))
  279.    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  280.        (princ (strcat "\n** Error: " msg " **")))
  281.    (princ)
  282. )
  283. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  284. (if (setq ss (ssget "_:N"))
  285.    (progn
  286.      (setq undo (not (vla-StartUndoMark doc)))
  287.      
  288.      (mapcar 'LM:RemovefromBlock
  289.        (vl-remove-if 'listp
  290.          (mapcar 'cadr (ssnamex ss))
  291.        )
  292.      )
  293.      
  294.      (setq undo (vla-EndUndoMark doc))
  295.    )
  296. )
  297. (princ)
  298. )

 
还包括“Removefromblock”选项。
回复

使用道具 举报

62

主题

466

帖子

404

银币

后起之秀

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

铜币
310
发表于 2022-7-6 11:22:37 | 显示全部楼层
李,
与以前的LISPS相比,你写了多少?
 
看看我的方法,使用其他Lisp开始,是不是一个坏主意。。我倾向于修改比我从头开始写更多的内容
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:27:05 | 显示全部楼层
我有一个大约400个子库,我从中提取,当使用它们时,我会查看它们的改进-其余的都是从头开始的。
回复

使用道具 举报

62

主题

466

帖子

404

银币

后起之秀

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

铜币
310
发表于 2022-7-6 11:32:39 | 显示全部楼层
 
美好的我以为你有一堆诡计。我知道这是一个愚蠢的问题,但我总是担心我是否朝着正确的方向前进。从外表上看,你很有条理。这是我必须努力的事情。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:42:13 | 显示全部楼层
 
谢谢-我不会担心走错方向,只有在一路上犯了几个错误,你才会学到东西。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 16:51 , Processed in 0.499945 second(s), 72 queries .

© 2020-2025 乐筑天下

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