代码现在是1括号错误,以找到数字可能有帮助(定义blc的vlax;22应该是1或只是缺少LM的结束语:deletblocks
- look at end of line0;;--------------------=={ Delete Blocks }==-------------------;;;00
- 0;; ;;;00
- 0;; Deletes all references of a list of blocks from a drawing ;;;00
- 0;; (including nested references, nested to any level). ;;;00
- 0;; Proceeds to delete the associated block definitions from ;;;00
- 0;; the drawing, if possible. ;;;00
- 0;; ;;;00
- 0;; This function is compatible with ObjectDBX. ;;;00
- 0;;------------------------------------------------------------;;;00
- 0;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;;00
- 0;;------------------------------------------------------------;;;00
- 0;; Arguments: ;;;00
- 0;; doc - VLA Document Object ;;;00
- 0;; lst - List of blocks to be deleted (case insensitive) ;;;00
- 0;;------------------------------------------------------------;;;00
- 0;; Returns: List of blocks that were successfully deleted. ;;;00
- 0;;------------------------------------------------------------;;;00
- 0 ;00
- 1(defun LM:deleteblocks ( doc lst / blc bln lck rtn );11
- 2 (setq blc (vla-get-blocks doc);22
- 2 lst (mapcar 'strcase lst);22
- 1 );11
- 2 (vlax-for lay (vla-get-layers doc);22
- 3 (if (= :vlax-true (vla-get-lock lay));33
- 3 (progn (setq lck (cons lay lck)) (vla-put-lock lay :vlax-false));33
- 2 );22
- 1 );11
- 2 (vlax-for def blc;22
- 3 (vlax-for obj def;33
- 4 (if ;44
- 5 (and (= "AcDbBlockReference" (vla-get-objectname obj));55
- 6 (or ;66
- 7 (and (vlax-property-available-p obj 'effectivename);77
- 7 (setq bln (strcase (vla-get-effectivename obj)));77
- 6 );66
- 7 (setq bln (strcase (vla-get-name obj));77
- 6 );66
- 6 (vl-some '(lambda ( x ) (wcmatch bln x)) lst);66
- 5 );55
- 6 (progn;66
- 6 (vl-catch-all-apply 'vla-delete (list obj));66
- 6 (or (member bln rtn) (setq rtn (cons bln rtn)));66
- 5 );55
- 4 );44
- 3 );33
- 2 );22
- 2 (foreach lay lck (vla-put-lock lay :vlax-true));22
- 2 (vl-remove-if '(lambda ( x ) (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list (vla-item blc x))))) rtn);22
- 1);11
- 11111;
- ; this should be 0 if ok
|