ODA File Converter Support

Use an installed ODA File Converter for converting between different versions of .dwg, .dxb and .dxf.

Warning

Execution of an external application is a big security issue! Especially when the path to the executable can be altered.

To avoid this problem delete the ezdxf.addons.odafc.py module.

The ODA File Converter has to be installed by the user, the application is available for Windows XP, Windows 7 or later, Mac OS X, and Linux in 32/64-bit RPM and DEB format.

At least at Windows the GUI of the ODA File Converter pops up on every call.

ODA File Converter version strings, you can use any of this strings to specify a version, 'R..' and 'AC....' strings will be automatically mapped to 'ACAD....' strings:

ODAFC ezdxf Version
ACAD9 not supported AC1004
ACAD10 not supported AC1006
ACAD12 R12 AC1009
ACAD13 R13 AC1012
ACAD14 R14 AC1014
ACAD2000 R2000 AC1015
ACAD2004 R2004 AC1018
ACAD2007 R2007 AC1021
ACAD2010 R2010 AC1024
ACAD2013 R2013 AC1027
ACAD2018 R2018 AC1032

Usage:

from ezdxf.addons import odafc

# Load a DWG file
doc = odafc.readfile('my.dwg')

# Use loaded document like any other ezdxf document
print(f'Document loaded as DXF version: {doc.dxfversion}.')
msp = doc.modelspace()
...

# Export document as DWG file for AutoCAD R2018
odafc.export_dwg(doc, 'my_R2018.dwg', version='R2018')
ezdxf.addons.odafc.exec_path

Path to installed ODA File Converter executable, default is "C:\Program Files\ODA\ODAFileConverter\ODAFileConverter.exe".

ezdxf.addons.odafc.temp_path

Path to a temporary folder by default the system temp folder defined by environment variable TMP or TEMP.

ezdxf.addons.odafc.readfile(filename: str, version: str = None, audit=False) → Drawing

Use an installed ODA File Converter to convert a DWG/DXB/DXF file into a temporary DXF file and load this file by ezdxf.

Parameters:
  • filename – file to load by ODA File Converter
  • version – load file as specific DXF version, by default the same version as the source file or if not detectable the latest by ezdxf supported version.
  • audit – audit source file before loading
ezdxf.addons.odafc.export_dwg(doc: Drawing, filename: str, version: str = None, audit=False, replace=False) → None

Use an installed ODA File Converter to export a DXF document doc as a DWG file.

Saves a temporary DXF file and convert this DXF file into a DWG file by the ODA File Converter. If version is not specified the DXF version of the source document is used.

Parameters:
  • docezdxf DXF document as Drawing object
  • filename – export filename of DWG file, extension will be changed to “.dwg”
  • version – export file as specific version, by default the same version as the source document.
  • audit – audit source file by ODA File Converter at exporting
  • replace – replace existing DWG file if True

Changed in version 0.15: added replace option