jonesy 发表于 2013-5-28 05:51:26

从大量 DWG 到少量 DXF

我为我正在从事的道路项目提供了大量DWG格式的数字地形模型文件(总共+ 350个)。
我可以将它们转换为DXF,然后可以将其导入到我们的第三方建模软件中。但是,我一次只能做一个!
有没有人知道任何工具可以在一步过程中对所有文件进行此转换,并能够输出少量的DXF文件(例如5或6个dxf文件)。
提前致谢
T
**** Hidden Message *****

BlackBox 发表于 2013-5-28 16:50:57

给你,琼斯……这将批量将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例程

jonesy 发表于 2013-5-29 08:10:35

非常感谢。我会试一试的。
页: [1]
查看完整版本: 从大量 DWG 到少量 DXF