# brad/inkscape-openscad-dxf-export architecture

> Architecture diagram of the GitHub repository brad/inkscape-openscad-dxf-export, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brad/inkscape-openscad-dxf-export
- Repository: https://github.com/brad/inkscape-openscad-dxf-export

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Systems
    InkscapeGUI("Inkscape GUI"):::external
    InkscapeGUI -->|triggers| InxDesc

    %% Integration Layer
    InxDesc[".inx descriptor"]:::integration
    InxDesc -->|launches| Controller

    click InxDesc "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf.inx"

    %% Core Plugin Package
    subgraph "openscad_dxf Package"
        PackageRoot["Package Root"]:::core
        Controller["openscad_dxf.py<br/>(Controller)"]:::core
        Inkex["inkinkex.py<br/>(API Wrapper)"]:::core
        Utils["inkutils.py<br/>(SVG Utilities)"]:::core
        ObjPath["object2path.py<br/>(Object Flattening)"]:::core
        DXFColor["dxf_color.py<br/>(DXF Generation)"]:::core

        PackageRoot --> Controller
        Controller --> Inkex
        Controller --> Utils
        Controller --> ObjPath
        Controller --> DXFColor
    end

    click PackageRoot "https://github.com/brad/inkscape-openscad-dxf-export/tree/master/openscad_dxf/"
    click Controller "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf/openscad_dxf.py"
    click Inkex "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf/inkinkex.py"
    click Utils "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf/inkutils.py"
    click ObjPath "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf/object2path.py"
    click DXFColor "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/openscad_dxf/dxf_color.py"

    %% Output Artifact
    DXFFile(("Output DXF File")):::artifact
    DXFColor -->|writes| DXFFile

    %% Test Harness
    subgraph "Tests & CI"
        TestFile["tests/test_save.py"]:::tests
        Fixtures(("tests/files<br/>(sample DXF fixtures)")):::tests
        TravisCI[".travis.yml"]:::ci
        ToxConfig["tox.ini"]:::ci

        TestFile --> PackageRoot
        TestFile --> Fixtures
    end

    click TestFile "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/tests/test_save.py"
    click Fixtures "https://github.com/brad/inkscape-openscad-dxf-export/tree/master/tests/files/"
    click TravisCI "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/.travis.yml"
    click ToxConfig "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/tox.ini"

    %% Packaging
    subgraph "Packaging"
        Setup["setup.py"]:::packaging
        Manifest["MANIFEST.in"]:::packaging
    end

    click Setup "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/setup.py"
    click Manifest "https://github.com/brad/inkscape-openscad-dxf-export/blob/master/MANIFEST.in"

    %% CI Relationship
    TravisCI --> TestFile
    ToxConfig --> TestFile

    %% Packaging Relationship
    Setup --> PackageRoot
    Manifest --> PackageRoot

    %% Styles
    classDef external fill:#a2fca2,stroke:#333,stroke-width:1px;
    classDef integration fill:#a2c4fc,stroke:#333,stroke-width:1px;
    classDef core fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef artifact fill:#fce4ec,stroke:#333,stroke-width:1px;
    classDef tests fill:#ffe5b4,stroke:#333,stroke-width:1px;
    classDef ci fill:#ffdead,stroke:#333,stroke-width:1px;
    classDef packaging fill:#e1bee7,stroke:#333,stroke-width:1px;
```
