How brad/inkscape-openscad-dxf-export works
Project type and purpose
• This is an open-source Inkscape extension written in Python that exports Inkscape SVG drawings as DXF files consumable by OpenSCAD.
• The .inx file integrates with Inkscape’s extension framework; the openscad_dxf Python package implements the export logic; tests verify correctness.
File structure
Top-level items:
• openscad_dxf.inx – Inkscape extension descriptor (menu entry, parameters).
• openscad_dxf/ – Python package with modules:
– inkinkex.py (wrapper around Inkex base class)
– inkutils.py (SVG→path utilities)
– object2path.py (object flattening)
– openscad_dxf.py (main entry point).
• setup.py, MANIFEST.in, packaging files – PyPI distribution.
• tests/ – unit tests and sample DXF files for CI.
• .travis.yml, tox.ini – CI configuration.
README for insights
• Describes installation into Inkscape’s global or user extensions directory.
Components and relationships
a. Main components:
1) Inkscape GUI (external system)
2) .inx descriptor (integration layer)
3) Python extension package (openscad_dxf)
– API wrapper (inkinkex)
– SVG preprocessing (inkutils, object2path)
– DXF generation (dxf_color)
– Controller (openscad_dxf.py)
4) Output DXF file
5) Test harness (pytest suite under tests/)
6) Packaging/CI (setup.py, Travis CI, tox)
b. Interactions:
– User triggers “Export as OpenSCAD DXF” → Inkscape reads .inx → launches openscad_dxf.py
– openscad_dxf.py uses inkinkex to parse CLI parameters and receive SVG DOM
– Preprocessing modules convert all objects to path commands
– Controller writes out DXF file to disk
– tests invoke openscad_dxf.py programmatically against sample DXF files to verify output
c. Architectural patterns/principles:
– Modular plugin architecture (Separation of concerns between integration, preprocessing, and output)
– Layered processing pipeline (parse → preprocess → generate → write)
– Test-driven design (sample files + unit tests)
d. Key technologies/frameworks:
– Python 3.x (extension code)
– Inkex (Inkscape’s Python extension API)
– pytest (test suite)
– setuptools (packaging)
– CI: Travis CI, tox