youngsoo
2007-10-10, 02:22 AM
Hi AUGI members!
I have a lisp routine.
http://dwg.ru/forum/viewtopic.php?t=15816&sid=e456dfa4268533939337b257f6ca5148
I have loaded it into 2007 and the error "Automation Error. Problem in loading application"
Sorry! I can't explain enough. I must be study English.
Please modify.
(defun C:BatchPurge ( / cmd n_doc ShellApp Dir dir_lst file_lst folItm UnPrg UnPrgLst Prg lst msg)
(vl-load-com)
(setq cmd (getvar "CMDECHO")
n_doc (vla-getinterfaceobject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16")
Prg 0 UnPrg 0);setq
(if (and (setq ShellApp (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(setq Dir (vlax-invoke-method ShellApp 'BrowseForFolder 0
"Select Direcory to Purge Files in" 0)));and
(progn (setq dir_lst (list Dir))
(vlax-release-object ShellApp) (setq ShellApp nil)
(while dir_lst (setq itms (vlax-invoke-method (car dir_lst) 'Items)
cnt (1- (vla-get-count itms)));setq
(while (< 0 cnt) (setq itm (vla-item itms cnt))
(if (= :vlax-true (vlax-get-property itm 'IsFileSystem))
(cond ((= "AutoCAD Drawing" (vla-get-Type itm))
(setq file_lst (cons (vla-get-Path itm) file_lst)))
((= :vlax-true (vlax-get-property itm 'IsFolder))
(if (setq folItm (vl-catch-all-apply 'vlax-get-property (list itm 'GetFolder)))
(setq dir_lst (cons folItm dir_lst))))));if
(setq cnt (1- cnt)));while
(setq dir_lst (cdr (reverse dir_lst))));while
);progn
file_lst
);if
(foreach dwg file_lst
(vla-open n_doc (findfile dwg))
(if (not (vlax-method-applicable-p n_doc 'PurgeAll))
(progn (setq UnPrg (1+ UnPrg)
UnPrgLst (cons (vla-get-name n_doc) UnPrgLst))
(vla-close n_doc :vlax-false));progn
(progn (repeat 2 (vla-purgeall n_doc))
(vla-close n_doc :vlax-true)
(setq Prg (1+ Prg))));if
);foreach
(while UnPrgLst (setq lst (if lst (strcat lst "\n" (car UnPrgLst)) (car UnPrgLst))
UnPrgLst (cdr UnPrgLst)));while
(setq msg1 (if (= Prg 0) "No Purged Files"
(strcat "Congratulations! Purge Completed.\n" (itoa Prg) "Files Purged"))
msg2 (strcat (itoa UnPrg) " Files Not Purged: \n" lst));setq
(alert (strcat msg1 msg2))
);end
I have a lisp routine.
http://dwg.ru/forum/viewtopic.php?t=15816&sid=e456dfa4268533939337b257f6ca5148
I have loaded it into 2007 and the error "Automation Error. Problem in loading application"
Sorry! I can't explain enough. I must be study English.
Please modify.
(defun C:BatchPurge ( / cmd n_doc ShellApp Dir dir_lst file_lst folItm UnPrg UnPrgLst Prg lst msg)
(vl-load-com)
(setq cmd (getvar "CMDECHO")
n_doc (vla-getinterfaceobject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16")
Prg 0 UnPrg 0);setq
(if (and (setq ShellApp (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(setq Dir (vlax-invoke-method ShellApp 'BrowseForFolder 0
"Select Direcory to Purge Files in" 0)));and
(progn (setq dir_lst (list Dir))
(vlax-release-object ShellApp) (setq ShellApp nil)
(while dir_lst (setq itms (vlax-invoke-method (car dir_lst) 'Items)
cnt (1- (vla-get-count itms)));setq
(while (< 0 cnt) (setq itm (vla-item itms cnt))
(if (= :vlax-true (vlax-get-property itm 'IsFileSystem))
(cond ((= "AutoCAD Drawing" (vla-get-Type itm))
(setq file_lst (cons (vla-get-Path itm) file_lst)))
((= :vlax-true (vlax-get-property itm 'IsFolder))
(if (setq folItm (vl-catch-all-apply 'vlax-get-property (list itm 'GetFolder)))
(setq dir_lst (cons folItm dir_lst))))));if
(setq cnt (1- cnt)));while
(setq dir_lst (cdr (reverse dir_lst))));while
);progn
file_lst
);if
(foreach dwg file_lst
(vla-open n_doc (findfile dwg))
(if (not (vlax-method-applicable-p n_doc 'PurgeAll))
(progn (setq UnPrg (1+ UnPrg)
UnPrgLst (cons (vla-get-name n_doc) UnPrgLst))
(vla-close n_doc :vlax-false));progn
(progn (repeat 2 (vla-purgeall n_doc))
(vla-close n_doc :vlax-true)
(setq Prg (1+ Prg))));if
);foreach
(while UnPrgLst (setq lst (if lst (strcat lst "\n" (car UnPrgLst)) (car UnPrgLst))
UnPrgLst (cdr UnPrgLst)));while
(setq msg1 (if (= Prg 0) "No Purged Files"
(strcat "Congratulations! Purge Completed.\n" (itoa Prg) "Files Purged"))
msg2 (strcat (itoa UnPrg) " Files Not Purged: \n" lst));setq
(alert (strcat msg1 msg2))
);end