给你,琼斯……这将批量将DWG目录导出到DXF(
同一目录
):
- (vl-load-com)
-
- (defun c:BExpDxf () (c:BatchExportDxf))
- (defun c:BatchExportDxf (/ *error* acApp acDocs dwgName oShell oFolder
- path dwgs filePath dbxDoc filePath
- )
- (princ "\rBATCHEXPORTDXF ")
-
- (defun *error* (msg)
- (if oShell
- (vlax-release-object oShell)
- )
- (if dbxDoc
- (vlax-release-object dbxDoc)
- )
- (cond ((not msg)) ; Normal exit
- ((member msg '("Function cancelled" "quit / exit abort"))) ; or (quit)
- ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
- )
- (princ)
- )
-
- (if (and (setq acApp (vlax-get-acad-object))
- (setq acDocs (vla-get-documents acApp))
- (setq dwgName (getvar 'dwgname))
- (setq oShell (vla-getinterfaceobject
- acApp
- "Shell.Application"
- )
- )
- (setq oFolder (vlax-invoke
- oShell
- 'BrowseForFolder
- (vla-get-hwnd acApp)
- "Select folder to process:"
- 0
- 321
- )
- )
- (setq path (vlax-get-property
- (vlax-get-property oFolder 'Self)
- 'Path
- )
- )
- (setq dwgs (vl-directory-files path "*.dwg" 1))
- (princ "\nProcessing drawings, please wait...")
- (princ)
- (setq dbxDoc (vla-getinterfaceobject
- acApp
- (strcat "ObjectDBX.AxDbDocument."
- (substr (getvar 'acadver) 1 2)
- )
- )
- )
- )
- (progn
- (foreach dwg dwgs
- (if (/= dwg dwgName)
- (progn
- (vl-catch-all-apply
- 'vla-open
- (list dbxDoc (setq filePath (strcat path "\" dwg)))
- )
- (vla-saveas
- dbxDoc
- (strcat (vl-filename-directory filePath)
- "\"
- (vl-filename-base filePath)
- ".dxf"
- )
- )
- )
- )
- )
- (princ "Done.")
- )
- )
- (*error* nil)
- )
-
**我所有的批处理*例程(Civil 3D和AutoCAD)最初都是受RobertB中对ObjectDBX了解甚少的启发,后来是Lee的BFIND例程
|