# grilled-swampert/polyline-blender-addon architecture

> Architecture diagram of the GitHub repository grilled-swampert/polyline-blender-addon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grilled-swampert/polyline-blender-addon
- Repository: https://github.com/grilled-swampert/polyline-blender-addon

## Overview

##### Project type and purpose
- From the file‐tree and naming conventions, this is a Python-based graphics/drawing plugin (very reminiscent of a Blender add-on):
- It has “operators” and “panels” (typical for an event-driven UI within a host application).
- It generates polylines, arcs, helices, splines, checks collisions, and syncs endpoints.
- The purpose is to let users interact via GUI panels, invoke operators that compute geometric point sequences, store state, and render those polylines in real time.

##### File structure
- Top-level:
- main.py – registers the add-on or entry point
- drawing/ – modules that actually render geometry (draw_polylines.py, sync_endpoint_timer.py)
- operators/ – user-action handlers (operators/main.py)
- panels/ – UI definitions (main_panel.py, list_panel.py, points_panel.py)
- properties/ – definitions of UI properties and list items (polylinelistitem.py)
- structures/ – core data models (structures/main.py)
- utility/ – helper functions to generate geometric points and manage global state (generate_*.py, check_collision.py, endpoint_positions.py, global_storage.py)
- No build scripts; deployment is by installing the Python package or dropping into the host’s add-on folder.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point
    EntryPoint["main.py\n(Add-on Entry Point)"]:::entry

    %% External Host
    HostAPI["Blender API (bpy)"]:::external

    %% Layers
    subgraph "UI Layer"
        direction TB
        MainPanel["MainPanel (panels/main_panel.py)"]:::ui
        ListPanel["ListPanel (panels/list_panel.py)"]:::ui
        PointsPanel["PointsPanel (panels/points_panel.py)"]:::ui
    end

    subgraph "Operator Layer"
        direction TB
        OperatorMain["OperatorMain (operators/main.py)"]:::operator
    end

    subgraph "Model Layer"
        direction TB
        StructuresMain["StructuresMain (structures/main.py)"]:::model
        PolylineListItem["PolylineListItem (properties/polylinelistitem.py)"]:::model
    end

    subgraph "Utility Layer"
        direction TB
        GenerateLinear["generate_linear_points.py"]:::util
        GenerateArc["generate_arc_points.py"]:::util
        GenerateHelix["generate_helix_points.py"]:::util
        GenerateSpline["generate_spline_points.py"]:::util
        CheckCollision["check_collision.py"]:::util
        EndpointPositions["endpoint_positions.py"]:::util
    end

    GlobalStorage["global_storage.py\n(Global State Manager)"]:::model

    subgraph "Drawing Engine"
        direction TB
        DrawPolylines["draw_polylines.py"]:::drawing
        SyncTimer["sync_endpoint_timer.py"]:::drawing
    end

    %% Connections
    MainPanel -->|"execute()"| OperatorMain
    ListPanel -->|"execute()"| OperatorMain
    PointsPanel -->|"execute()"| OperatorMain

    OperatorMain -->|"uses Properties"| StructuresMain
    OperatorMain -->|"uses Properties"| PolylineListItem

    OperatorMain -->|"get_points()"| GenerateLinear
    OperatorMain -->|"get_points()"| GenerateArc
    OperatorMain -->|"get_points()"| GenerateHelix
    OperatorMain -->|"get_points()"| GenerateSpline
    OperatorMain -->|"check()"| CheckCollision
    OperatorMain -->|"get_positions()"| EndpointPositions

    GenerateLinear -->|"store points"| GlobalStorage
    GenerateArc -->|"store points"| GlobalStorage
    GenerateHelix -->|"store points"| GlobalStorage
    GenerateSpline -->|"store points"| GlobalStorage
    CheckCollision -->|"reads points"| GlobalStorage
    EndpointPositions -->|"updates endpoints"| GlobalStorage

    OperatorMain -->|"draw()"| DrawPolylines
    SyncTimer -->|"on change"| DrawPolylines

    GlobalStorage -->|"state"| SyncTimer
    DrawPolylines -->|"render()"| HostAPI

    EntryPoint -->|"registers Operators & Panels"| HostAPI
    EntryPoint -->|"entry point"| OperatorMain
    EntryPoint -->|"entry point"| MainPanel

    %% Click Events
    click MainPanel "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/panels/main_panel.py"
    click ListPanel "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/panels/list_panel.py"
    click PointsPanel "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/panels/points_panel.py"
    click OperatorMain "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/operators/main.py"
    click StructuresMain "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/structures/main.py"
    click PolylineListItem "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/properties/polylinelistitem.py"
    click GenerateLinear "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/generate_linear_points.py"
    click GenerateArc "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/generate_arc_points.py"
    click GenerateHelix "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/generate_helix_points.py"
    click GenerateSpline "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/generate_spline_points.py"
    click CheckCollision "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/check_collision.py"
    click EndpointPositions "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/endpoint_positions.py"
    click GlobalStorage "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/utility/global_storage.py"
    click DrawPolylines "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/drawing/draw_polylines.py"
    click SyncTimer "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/drawing/sync_endpoint_timer.py"
    click EntryPoint "https://github.com/grilled-swampert/polyline-blender-addon/blob/main/main.py"

    %% Styles
    classDef ui fill:#cbe7ff,stroke:#0366d6,color:#0366d6;
    classDef operator fill:#b7e4c7,stroke:#2d6a4f,color:#2d6a4f;
    classDef util fill:#fff3bf,stroke:#f08c00,color:#995c00;
    classDef model fill:#e0e0e0,stroke:#6c757d,color:#343a40;
    classDef drawing fill:#ffd8a8,stroke:#e85d04,color:#9d0208;
    classDef external fill:none,stroke:#adb5bd,stroke-dasharray: 5 5,color:#495057;
    classDef entry fill:#d0ebff,stroke:#339af0,color:#1c7ed6;
```
