尝试加载以下(未测试)代码来代替我的删除块程序:
- ;;--------------------=={ Delete Blocks }==-------------------;;
- ;; ;;
- ;; Deletes all references of a list of blocks from a drawing ;;
- ;; (including nested references, nested to any level). ;;
- ;; Proceeds to delete the associated block definitions from ;;
- ;; the drawing, if possible. ;;
- ;; ;;
- ;; This function is compatible with ObjectDBX. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; doc - VLA Document Object ;;
- ;; lst - List of blocks to be deleted (case insensitive) ;;
- ;;------------------------------------------------------------;;
- ;; Returns: List of blocks that were successfully deleted. ;;
- ;;------------------------------------------------------------;;
- (defun LM:deleteblocks ( doc lst / blc bln lck rtn )
- (setq blc (vla-get-blocks doc)
- lst (mapcar 'strcase lst)
- )
- (vlax-for lay (vla-get-layers doc)
- (if (= :vlax-true (vla-get-lock lay))
- (progn (setq lck (cons lay lck)) (vla-put-lock lay :vlax-false))
- )
- )
- (vlax-for def blc
- (vlax-for obj def
- (if
- (and (= "AcDbBlockReference" (vla-get-objectname obj))
- (or
- (and (vlax-property-available-p obj 'effectivename)
- (setq bln (strcase (vla-get-effectivename obj)))
- )
- (setq bln (strcase (vla-get-name obj)))
- )
- (vl-some '(lambda ( x ) (wcmatch bln x)) lst)
- )
- (progn
- (vl-catch-all-apply 'vla-delete (list obj))
- (or (member bln rtn) (setq rtn (cons bln rtn)))
- )
- )
- )
- )
- (foreach lay lck (vla-put-lock lay :vlax-true))
- (vl-remove-if '(lambda ( x ) (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list (vla-item blc x))))) rtn)
- )
我会在适当的时候更新我网站上的程序。 |