# hlorus/cad_sketcher architecture

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

- Interactive diagram: https://gitdiagram.com/hlorus/cad_sketcher
- Repository: https://github.com/hlorus/cad_sketcher

## Overview

CAD Sketcher is a Blender extension for editable, constraint-driven 2D/3D sketching and part creation. Users create sketch geometry with viewport tools, add geometric or dimensional constraints, and rely on the solver to resolve the sketch; viewport drawing and picking support that interaction. The broader feature set includes workplanes, projection, modifiers/part operations, arrays, booleans and IFC export. Relationships below follow the sampled source references and README; several capability branches are documented but their runtime wiring was not sampled.

Main entry points: [`operators`](https://github.com/hlorus/cad_sketcher/tree/main/operators) (Sketch operators), [`model/curve_ref.py`](https://github.com/hlorus/cad_sketcher/blob/main/model/curve_ref.py) (Geometry references), [`draw_handler.py`](https://github.com/hlorus/cad_sketcher/blob/main/draw_handler.py) (Viewport drawing), [`workspacetools`](https://github.com/hlorus/cad_sketcher/tree/main/workspacetools) (Sketch tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Viewport interaction"]
  node_tools["Sketch tools"]
  node_operators["Sketch operators"]
  node_stateful["Tool state machine<br/>[logic.py]"]
  node_selection["Selection state<br/>[selection.py]"]
  node_ui["Panels and menus"]
end

subgraph group_sketch["Sketch model"]
  node_sketchref["Sketch access<br/>[sketch_ref.py]"]
  node_curveref["Geometry references<br/>[curve_ref.py]"]
  node_curvedata[("Curve data<br/>[curve_data.py]")]
  node_workplanes["Workplanes<br/>[workplane.py]"]
end

subgraph group_solve["Constraints and solving"]
  node_constraints["Constraint model<br/>[base_constraint.py]"]
  node_constrainttypes["Constraint types"]
  node_solver["Constraint solver<br/>[curve_solver.py]"]
end

subgraph group_parts["Part operations"]
  node_partops["Part and modifiers<br/>[modifiers.py]"]
  node_partmodel["Part modeling<br/>[part.py]"]
  node_projection["Geometry projection"]
  node_ifc["IFC export<br/>[ifc_export.py]"]
end

subgraph group_support["Display and integration"]
  node_draw["Viewport drawing<br/>[draw_handler.py]"]
  node_renderdata["Render data<br/>[render_data.py]"]
  node_constrainticons["Constraint icons"]
  node_gizmos["Viewport gizmos"]
end

node_blender(("Blender user"))

node_blender -.->|"starts tools"| node_tools
node_tools -->|"uses states"| node_stateful
node_tools -.->|"invokes tools"| node_operators
node_blender -.->|"uses panels"| node_ui
node_operators -.->|"updates selection"| node_selection
node_sketchref -->|"calls solve"| node_solver
node_curveref -->|"reads geometry"| node_curvedata
node_constraints -->|"resolves curves"| node_curveref
node_constraints -.->|"creates solver data"| node_solver
node_draw -->|"uses render data"| node_renderdata
node_draw -->|"draws icons"| node_constrainticons
node_draw -->|"reads selection"| node_selection
node_constrainticons -->|"reads highlights"| node_selection
node_gizmos -.->|"uses geometry"| node_curveref
node_partops -->|"uses curve data"| node_curvedata
node_partmodel -->|"uses modifiers"| node_partops
node_projection -->|"references curves"| node_curveref
node_ifc -.->|"exports model"| node_blender
node_operators -.->|"edits workplanes"| node_workplanes
node_operators -.->|"adds constraints"| node_constraints

click node_tools "https://github.com/hlorus/cad_sketcher/tree/main/workspacetools"
click node_operators "https://github.com/hlorus/cad_sketcher/tree/main/operators"
click node_stateful "https://github.com/hlorus/cad_sketcher/blob/main/stateful_operator/logic.py"
click node_selection "https://github.com/hlorus/cad_sketcher/blob/main/drawing/selection.py"
click node_sketchref "https://github.com/hlorus/cad_sketcher/blob/main/model/sketch_ref.py"
click node_curveref "https://github.com/hlorus/cad_sketcher/blob/main/model/curve_ref.py"
click node_curvedata "https://github.com/hlorus/cad_sketcher/blob/main/utilities/curve_data.py"
click node_workplanes "https://github.com/hlorus/cad_sketcher/blob/main/utilities/workplane.py"
click node_constraints "https://github.com/hlorus/cad_sketcher/blob/main/model/base_constraint.py"
click node_constrainttypes "https://github.com/hlorus/cad_sketcher/tree/main/model"
click node_solver "https://github.com/hlorus/cad_sketcher/blob/main/curve_solver.py"
click node_draw "https://github.com/hlorus/cad_sketcher/blob/main/draw_handler.py"
click node_renderdata "https://github.com/hlorus/cad_sketcher/blob/main/drawing/render_data.py"
click node_constrainticons "https://github.com/hlorus/cad_sketcher/blob/main/drawing/constraint_icons.py"
click node_gizmos "https://github.com/hlorus/cad_sketcher/tree/main/gizmos"
click node_partops "https://github.com/hlorus/cad_sketcher/blob/main/operators/modifiers.py"
click node_partmodel "https://github.com/hlorus/cad_sketcher/blob/main/utilities/part.py"
click node_projection "https://github.com/hlorus/cad_sketcher/blob/main/utilities/projection_anchor.py"
click node_ifc "https://github.com/hlorus/cad_sketcher/blob/main/utilities/ifc_export.py"
click node_ui "https://github.com/hlorus/cad_sketcher/tree/main/ui"

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_tools,node_operators,node_stateful,node_selection,node_ui,node_blender toneBlue
class node_sketchref,node_curveref,node_curvedata,node_workplanes toneAmber
class node_constraints,node_constrainttypes,node_solver toneMint
class node_partops,node_partmodel,node_projection,node_ifc toneRose
class node_draw,node_renderdata,node_constrainticons,node_gizmos toneIndigo
```

## Components

### Viewport interaction

- [Sketch tools](https://github.com/hlorus/cad_sketcher/tree/main/workspacetools): `workspacetools`
- [Sketch operators](https://github.com/hlorus/cad_sketcher/tree/main/operators): `operators`
- [Tool state machine](https://github.com/hlorus/cad_sketcher/blob/main/stateful_operator/logic.py): `stateful_operator/logic.py`
- [Selection state](https://github.com/hlorus/cad_sketcher/blob/main/drawing/selection.py): `drawing/selection.py`
- [Panels and menus](https://github.com/hlorus/cad_sketcher/tree/main/ui): `ui`

### Sketch model

- [Sketch access](https://github.com/hlorus/cad_sketcher/blob/main/model/sketch_ref.py): `model/sketch_ref.py`
- [Geometry references](https://github.com/hlorus/cad_sketcher/blob/main/model/curve_ref.py): `model/curve_ref.py`
- [Curve data](https://github.com/hlorus/cad_sketcher/blob/main/utilities/curve_data.py): `utilities/curve_data.py`
- [Workplanes](https://github.com/hlorus/cad_sketcher/blob/main/utilities/workplane.py): `utilities/workplane.py`

### Constraints and solving

- [Constraint model](https://github.com/hlorus/cad_sketcher/blob/main/model/base_constraint.py): `model/base_constraint.py`
- [Constraint types](https://github.com/hlorus/cad_sketcher/tree/main/model): `model`
- [Constraint solver](https://github.com/hlorus/cad_sketcher/blob/main/curve_solver.py): `curve_solver.py`

### Part operations

- [Part and modifiers](https://github.com/hlorus/cad_sketcher/blob/main/operators/modifiers.py): `operators/modifiers.py`
- [Part modeling](https://github.com/hlorus/cad_sketcher/blob/main/utilities/part.py): `utilities/part.py`
- [Geometry projection](https://github.com/hlorus/cad_sketcher/blob/main/utilities/projection_anchor.py): `utilities/projection_anchor.py`
- [IFC export](https://github.com/hlorus/cad_sketcher/blob/main/utilities/ifc_export.py): `utilities/ifc_export.py`

### Display and integration

- [Viewport drawing](https://github.com/hlorus/cad_sketcher/blob/main/draw_handler.py): `draw_handler.py`
- [Render data](https://github.com/hlorus/cad_sketcher/blob/main/drawing/render_data.py): `drawing/render_data.py`
- [Constraint icons](https://github.com/hlorus/cad_sketcher/blob/main/drawing/constraint_icons.py): `drawing/constraint_icons.py`
- [Viewport gizmos](https://github.com/hlorus/cad_sketcher/tree/main/gizmos): `gizmos`

### Other components

- **Blender user**

## Connections

- Blender user → Sketch tools: starts tools
- Sketch tools → Tool state machine: uses states (evidence: `workspacetools/manager.py`)
- Sketch tools → Sketch operators: invokes tools
- Blender user → Panels and menus: uses panels
- Sketch operators → Selection state: updates selection (evidence: `operators/context_menu.py`)
- Sketch access → Constraint solver: calls solve (evidence: `model/sketch_ref.py`)
- Geometry references → Curve data: reads geometry (evidence: `model/curve_ref.py`)
- Constraint model → Geometry references: resolves curves (evidence: `model/base_constraint.py`)
- Constraint model → Constraint solver: creates solver data
- Viewport drawing → Render data: uses render data (evidence: `draw_handler.py`)
- Viewport drawing → Constraint icons: draws icons (evidence: `draw_handler.py`)
- Viewport drawing → Selection state: reads selection (evidence: `draw_handler.py`)
- Constraint icons → Selection state: reads highlights (evidence: `drawing/constraint_icons.py`)
- Viewport gizmos → Geometry references: uses geometry
- Part and modifiers → Curve data: uses curve data (evidence: `utilities/curve_data.py`)
- Part modeling → Part and modifiers: uses modifiers (evidence: `utilities/part.py`)
- Geometry projection → Geometry references: references curves (evidence: `utilities/projection_anchor.py`)
- IFC export → Blender user: exports model
- Sketch operators → Workplanes: edits workplanes
- Sketch operators → Constraint model: adds constraints
