# solidcode/solidpython architecture

> Architecture diagram of the GitHub repository solidcode/solidpython, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/solidcode/solidpython
- Repository: https://github.com/solidcode/solidpython

## Overview

SolidPython is a Python interface for building OpenSCAD models and emitting SCAD text or files. The main workflow is to construct geometry with OpenSCAD-style primitives and CSG operations, then render the object tree; OpenSCAD can consume the generated file for preview or mesh rendering. Separate capabilities include importing existing SCAD modules, utilities for positioning and BOM work, and geometry-generation extensions. Edges follow the README or shown imports/calls; unsampled details are not inferred.

Main entry points: [`solid/objects.py`](https://github.com/solidcode/solidpython/blob/master/solid/objects.py) (OpenSCAD primitives), [`solid/solidpython.py`](https://github.com/solidcode/solidpython/blob/master/solid/solidpython.py) (SCAD renderer), [`solid/__init__.py`](https://github.com/solidcode/solidpython/blob/master/solid/__init__.py) (SolidPython API), [`solid/py_scadparser/scad_parser.py`](https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_parser.py) (SCAD importer parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model construction"]
  node_api["SolidPython API<br/>[__init__.py]"]
  node_primitives["OpenSCAD primitives<br/>[objects.py]"]
  node_euclid["Euclid compatibility<br/>[patch_euclid.py]"]
  node_utils["Model utilities<br/>[utils.py]"]
end

subgraph group_render["SCAD generation and import"]
  node_renderer["SCAD renderer<br/>[solidpython.py]"]
  node_parser["SCAD importer parser<br/>[scad_parser.py]"]
  node_tokens["SCAD lexer tokens<br/>[scad_tokens.py]"]
  node_ast["SCAD declarations AST<br/>[scad_ast.py]"]
  node_scadfile["Generated SCAD file"]
end

subgraph group_geometry["Geometry extensions"]
  node_path_extrude["Path extrusion"]
  node_spline["Spline surfaces<br/>[splines.py]"]
  node_threads["Screw threads<br/>[screw_thread.py]"]
end

node_developer(("Python model author"))
node_openscad["OpenSCAD"]

node_developer -->|"authors with"| node_api
node_api -->|"renders through"| node_renderer
node_api -->|"exposes"| node_primitives
node_api -->|"exposes patch"| node_euclid
node_primitives -->|"builds object tree"| node_renderer
node_utils -->|"uses primitives"| node_primitives
node_renderer -->|"writes SCAD"| node_scadfile
node_renderer -->|"parses imports"| node_parser
node_parser -->|"uses lexer"| node_tokens
node_parser -->|"builds declarations"| node_ast
node_scadfile -->|"opens or renders"| node_openscad
node_path_extrude -->|"creates polyhedra"| node_primitives
node_spline -->|"creates shapes"| node_primitives
node_threads -->|"creates CSG"| node_primitives
node_threads -->|"exports example"| node_renderer

click node_api "https://github.com/solidcode/solidpython/blob/master/solid/__init__.py"
click node_primitives "https://github.com/solidcode/solidpython/blob/master/solid/objects.py"
click node_euclid "https://github.com/solidcode/solidpython/blob/master/solid/patch_euclid.py"
click node_utils "https://github.com/solidcode/solidpython/blob/master/solid/utils.py"
click node_renderer "https://github.com/solidcode/solidpython/blob/master/solid/solidpython.py"
click node_parser "https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_parser.py"
click node_tokens "https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_tokens.py"
click node_ast "https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_ast.py"
click node_path_extrude "https://github.com/solidcode/solidpython/blob/master/solid/extrude_along_path.py"
click node_spline "https://github.com/solidcode/solidpython/blob/master/solid/splines.py"
click node_threads "https://github.com/solidcode/solidpython/blob/master/solid/screw_thread.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_primitives,node_euclid,node_utils toneBlue
class node_renderer,node_parser,node_tokens,node_ast,node_scadfile toneAmber
class node_path_extrude,node_spline,node_threads toneMint
class node_developer,node_openscad toneIndigo
```

## Components

### Model construction

- [SolidPython API](https://github.com/solidcode/solidpython/blob/master/solid/__init__.py): `solid/__init__.py`
- [OpenSCAD primitives](https://github.com/solidcode/solidpython/blob/master/solid/objects.py): `solid/objects.py`
- [Euclid compatibility](https://github.com/solidcode/solidpython/blob/master/solid/patch_euclid.py): `solid/patch_euclid.py`
- [Model utilities](https://github.com/solidcode/solidpython/blob/master/solid/utils.py): `solid/utils.py`

### SCAD generation and import

- [SCAD renderer](https://github.com/solidcode/solidpython/blob/master/solid/solidpython.py): `solid/solidpython.py`
- [SCAD importer parser](https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_parser.py): `solid/py_scadparser/scad_parser.py`
- [SCAD lexer tokens](https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_tokens.py): `solid/py_scadparser/scad_tokens.py`
- [SCAD declarations AST](https://github.com/solidcode/solidpython/blob/master/solid/py_scadparser/scad_ast.py): `solid/py_scadparser/scad_ast.py`
- **Generated SCAD file**

### Geometry extensions

- [Path extrusion](https://github.com/solidcode/solidpython/blob/master/solid/extrude_along_path.py): `solid/extrude_along_path.py`
- [Spline surfaces](https://github.com/solidcode/solidpython/blob/master/solid/splines.py): `solid/splines.py`
- [Screw threads](https://github.com/solidcode/solidpython/blob/master/solid/screw_thread.py): `solid/screw_thread.py`

### Other components

- **Python model author**
- **OpenSCAD**

## Connections

- Python model author → SolidPython API: authors with (evidence: `README.rst`)
- SolidPython API → SCAD renderer: renders through (evidence: `solid/__init__.py`)
- SolidPython API → OpenSCAD primitives: exposes (evidence: `solid/__init__.py`)
- SolidPython API → Euclid compatibility: exposes patch (evidence: `solid/__init__.py`)
- OpenSCAD primitives → SCAD renderer: builds object tree (evidence: `solid/objects.py`)
- Model utilities → OpenSCAD primitives: uses primitives (evidence: `solid/utils.py`)
- SCAD renderer → Generated SCAD file: writes SCAD (evidence: `README.rst`)
- SCAD renderer → SCAD importer parser: parses imports (evidence: `solid/solidpython.py`)
- SCAD importer parser → SCAD lexer tokens: uses lexer (evidence: `solid/py_scadparser/scad_parser.py`)
- SCAD importer parser → SCAD declarations AST: builds declarations (evidence: `solid/py_scadparser/scad_parser.py`)
- Generated SCAD file → OpenSCAD: opens or renders (evidence: `README.rst`)
- Path extrusion → OpenSCAD primitives: creates polyhedra (evidence: `solid/extrude_along_path.py`)
- Spline surfaces → OpenSCAD primitives: creates shapes (evidence: `solid/splines.py`)
- Screw threads → OpenSCAD primitives: creates CSG (evidence: `solid/screw_thread.py`)
- Screw threads → SCAD renderer: exports example (evidence: `solid/screw_thread.py`)
