如何删除一个已知块名的块?
如何删除一个已知块名的块?例如:我想删除名字为Axis-01块,用purge可以是可以,如下面的这个语句,但是这种语句多的话,执行好慢啊。还有什么更快的方法吗? 谢谢。
[*](command "-purge" "B" "Axis-01" "N")
;;36 [功能] 删除指定名的所有块
;; (MJ:EraseBlock "BTL");删除名叫"BTL"的所有块
(defun MJ:EraseBlock (bn / layout i)
(vlax-for layout *LOUTS*
(vlax-for i (vla-get-block layout)
(if (and
(= (vla-get-objectname i) "AcDbBlockReference")
(= (strcase (vla-get-name i)) (strcase bn))
)
(vla-Delete i)
)
)
)
)
;;28.1 [功能] 清理打开文档
(defun MJ:PurgeAllDocs (/ item cur)
(vlax-for item *DOCS*
(vla-PurgeAll item)
)
)
(LH:DELETETBLK "1")
;;28.1 [功能] 清理打开文档BLK
(defun LH:DELETETBLK (BLK / item cur)
(setq
*ACAD* (vlax-get-acad-object)
*DOC*(vla-get-ActiveDocument *ACAD*)
*BLKS* (vla-get-Blocks *DOC*)
)
(vlax-for item *BLKS*
(IF (= (VLA-GET-NAME ITEM) BLK)
(PROGN
(SETQ ERR (vl-catch-all-apply 'vla-delete (LIST item)))
(IF (vl-catch-all-error-p ERR)
(PROGN
(PRINC (vl-catch-all-error-message ERR))
)
)
)
)
)
)
(setq
*ACAD*(vlax-get-acad-object)
*DOC* (vla-get-ActiveDocument *ACAD*)
*BLKS*(vla-get-Blocks *DOC*)
*LAYS*(vla-get-Layers *DOC*)
*LTS* (vla-get-Linetypes *DOC*)
*STS* (vla-get-TextStyles *DOC*)
*GRPS*(vla-get-groups *DOC*)
*DIMS*(vla-get-DimStyles *DOC*)
*LOUTS* (vla-get-Layouts *DOC*)
)
(setq ss(ssget "A" '((2 . "Axis-01"))))
(if ss(command "erase" ss "")) (if(setq ss(ssget"x"'((2 . "Axis-01"))))(command"erase"ss"")) 本帖最后由 vpddup 于 2023-4-2 21:38 编辑
liuhe 发表于 2023-4-2 16:19
可能我没有说清楚。我是想清理这个块。这个块已经从图面上删除了,但还在块定义库中。 我想把它从块库删除。
DELETEBLK 这个函数好使,能够实现这个想法。谢谢
页:
[1]