A no-fuss Python CLI for converting AutoCAD .dwg files to .dxf (text format that ezdxf, QGIS, GIS pipelines, etc. can actually parse).
Built because:
libredwg-toolsis not packaged on Debian/Ubuntu (you have to build from source — and it's slow and fragile).- ODA File Converter is a Windows/Mac GUI tool; no clean Linux pipeline.
- Existing Python alternatives are commercial or read-only.
This tool wraps Aspose.CAD for Python (commercial, has a free tier with output watermark for evaluation) and adds:
- Clean CLI:
dwg2dxf input.dwg - Batch mode:
dwg2dxf ./drawings/*.dwg --out ./dxf/ - Glob patterns + recursion
.NETglobalization workaround baked in (you don't need to remember the env var)- Skips already-converted files unless
--force - Honest error messages and progress
pip install dwg2dxfOr directly:
pip install aspose-cad ezdxf
git clone https://github.com/zheimr/DWG-to-DXF-Converter
cd DWG-to-DXF-Converter
pip install -e .# Single file
dwg2dxf my_drawing.dwg
# → my_drawing.dxf
# Specify output
dwg2dxf my_drawing.dwg -o out/drawing.dxf
# Batch (whole directory)
dwg2dxf ./drawings/ --out ./dxf/
# Recursive
dwg2dxf ./projects/ --recursive --out ./dxf/
# Glob
dwg2dxf "site_*.dwg" --out ./dxf/
# Verify result with ezdxf
dwg2dxf my_drawing.dwg --verifyfrom dwg2dxf import convert
# Single file
convert('input.dwg', 'output.dxf')
# Batch
from dwg2dxf import batch_convert
results = batch_convert(['a.dwg', 'b.dwg'], output_dir='./dxf/')
print(f"Converted: {results['ok']}, Failed: {results['failed']}")✅ Works:
- DWG → DXF for AutoCAD 2000+ files
- Most geometry preserved (LINE, POLYLINE, CIRCLE, ARC, ELLIPSE)
- Layer names retained
- Coordinates preserved exactly
- Layouts, blocks, viewports
- Default export is DXF R12 (AC1009) — old format. Some entities downgrade:
INSERTblocks may become explodedPOLYLINEsTEXT/MTEXTmay be partially lost- Hatches preserved as outlines
- Free Aspose.CAD tier adds a small evaluation watermark to output. Get a license from Aspose for clean output.
- Speed: ~30-90s for a 50MB DWG on a modern CPU (single-threaded).
- Output DXF can be 30-100× larger than the source DWG (text format).
❌ Not supported:
- DWG password protection
- 3D solids (will downgrade to wireframe)
- Custom ARX/ObjectDBX entities
| Tool | Open source? | Setup | Output quality |
|---|---|---|---|
| This tool (aspose-cad backend) | ❌ (free tier) | pip install |
Good, R12 default |
libredwg (dwg2dxf) |
✅ GPL | Compile from source on Linux | Good, multi-version |
| ODA File Converter | ❌ (free for personal) | Windows/Mac GUI, headless via wine | Best |
| QCAD CE | ✅ GPL | Build from source | Good |
AutoCAD SaveAs |
❌ paid | Windows | Reference |
If you need true open source for production: spend the afternoon building libredwg from source. This tool is for "just need it working today".
Tried. Build hangs on submodule init in standard Docker images, requires swig, autoconf-archive, and CA cert fixes. Not packaged in Debian Stable, Ubuntu 22.04, or Ubuntu 24.04 repos as of mid-2026. If someone gets a clean Dockerfile working, PR welcome — happy to make this a multi-backend tool.
MIT — see LICENSE. Note that aspose-cad has its own commercial license; this wrapper code is MIT but the actual conversion happens through Aspose.
PRs welcome. Especially want:
- libredwg backend with automatic fallback
- ODA File Converter wrapper (when installed)
- Better DXF version control (currently locked to R12 from Aspose default)
- Conversion options (precision, layer filter, etc.)
- Tests with sample DWG files
This was extracted from a fiber optic infrastructure GIS project where we needed to extract manhole coordinates from 8 CAD drawings (350 MB total) of a municipal fiber network. After conversion to DXF, we used ezdxf to read polylines on Mobese_EK ODASI_TIP 10 layer and converted CAD coordinates to WGS84 via pyproj. End-to-end pipeline in ~50 lines of Python.
If you have a similar GIS-from-CAD use case and want a tip: AutoCAD drawings are usually in a local projected CRS. You'll need to find one reference point with known WGS84 coordinates to derive the affine transformation. Once anchored, all geometries flow.