# packtpublishing/python-scripting-in-blender architecture

> Architecture diagram of the GitHub repository packtpublishing/python-scripting-in-blender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/packtpublishing/python-scripting-in-blender
- Repository: https://github.com/packtpublishing/python-scripting-in-blender

## Overview

This repository is a chapter-by-chapter companion to a Blender Python scripting book. It is not a single application; it is a collection of independent examples that all run inside Blender’s Python environment and demonstrate progressively more capable scripting and add-on patterns.

The top-level structure is the main architectural clue: `ch1` through `ch12` each represent a learning stage, and each chapter contains one or more standalone scripts or add-on folders. There is no shared application runtime across chapters; each folder is a separate example boundary.

The core platform boundary is Blender itself. All meaningful code depends on `bpy` and Blender’s data model, context, operators, UI system, and add-on registration lifecycle. In other words, the repo’s “backend” is Blender’s scene/object system, not an external service or custom server.

Chapters 1–2 are introductory scripting examples. `ch1/OurFirstScript.py` is a basic script entry point, while `ch2` focuses on accessing Blender modules, Blender data, and user context. Architecturally, these are one-off procedural scripts that read and mutate Blender state directly.

Chapters 3–5 move into simple add-ons and UI integration. Examples like `the_simplest_add_on.py`, `object_collector.py`, `object_floor_transform.py`, and `very_simple_panel.py` show the transition from script-only logic to registered add-ons with operators and panels. The important boundary here is between core action logic and Blender UI/registration hooks.

Chapter 6 is the clearest “mini-application” in the repo: `structured_addon/` is a package with multiple modules. It separates responsibilities into `operators.py`, `panel.py`, `objects_panel.py`, `preferences.py`, `img_loader.py`, and package initialization in `__init__.py`. This is the repo’s main example of layered add-on architecture: shared package state, operator logic, UI panels, add-on preferences, and asset loading.

The `structured_addon` folder also contains `pictures` and a `_refresh_.py` helper, which suggests bundled UI/media assets and a reload/refresh workflow during development. This is a useful diagram boundary: code modules in one group, packaged resources in another.

Chapters 7–9 focus on event-driven and animation-related tools. Scripts such as `action_to_range.py`, `vert_runner.py`, `object_shaker.py`, and `pendulum.py` imply manipulation of animation data, object motion, and time-based behavior. These examples likely interact with Blender’s action/animation system and scene updates rather than just static object creation.

Chapter 8 includes `_scenes_/ani_loop.blend`, which is a sample Blender scene asset used as input data for the chapter’s automation or animation example. This introduces a data-file boundary separate from Python code: the scene file is loaded into Blender and then modified by scripts/add-ons.

Later chapters continue the pattern of self-contained tools. `ch10/addons/punchclock.py`, `ch11/addons/latte_express.py`, and `ch12/addons/textament.py` are each standalone add-ons, likely demonstrating more advanced event handling, UI, or content-generation workflows. Each sits under its own chapter rather than sharing a monolithic codebase.

The repository also contains chapter-local media assets, especially under `ch12/_media_/textures` and `ch6/addons/structured_addon/pictures`. These support the add-ons visually, so the architecture includes bundled assets alongside Python code rather than relying on external asset management.

From an architecture-diagram perspective, the key flow is: user action inside Blender UI or script execution → add-on/operator logic in Python → Blender API (`bpy`) → Blender scene/data/UI state. In some chapters, the flow also includes packaged chapter assets such as textures, images, or `.blend` files.

Tooling is intentionally minimal. The repo is designed to be opened in Blender 3.3 and edited in VS Code; there is no custom build system, service layer, or deployment pipeline. Installation/distribution concepts appear only in the context of Blender add-ons.

So the repository’s architecture is best understood as a set of isolated Blender example modules grouped by learning topic, with a progression from procedural scripts to registered add-ons, from direct data manipulation to UI-driven and animation-driven tools, and from single-file examples to a structured package with resources and preferences.

Main entry points: [`ch6/addons/structured_addon/__init__.py`](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/__init__.py) (Structured addon), [`ch6/addons/structured_addon/operators.py`](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/operators.py) (Operators), [`ch8/addons/object_shaker.py`](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch8/addons/object_shaker.py) (Object shaker), [`ch12/addons/textament.py`](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch12/addons/textament.py) (Textament)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Blender platform"]
  node_blender_api[("Blender API<br/>runtime/bpy")]
end

subgraph group_early["Early chapters"]
  node_ch1_script["First script<br/>procedural script<br/>[OurFirstScript.py]"]
  node_ch2_examples["Context basics<br/>script examples"]
end

subgraph group_addons["Add-on chapters"]
  node_ch3_simple_addon["Simple add-on<br/>addon"]
  node_ch3_entry["Addon start<br/>addon entry"]
  node_ch4_floor_transform["Floor transform<br/>addon operator"]
  node_ch5_panel["Simple panel<br/>ui addon"]
end

subgraph group_structured["Structured add-on"]
  node_ch6_package["Structured addon<br/>addon package<br/>[__init__.py]"]
  node_ch6_ops["Operators<br/>[operators.py]"]
  node_ch6_panel["Main panel<br/>[panel.py]"]
  node_ch6_objects_panel["Objects panel<br/>[objects_panel.py]"]
  node_ch6_prefs["Preferences<br/>[preferences.py]"]
  node_ch6_loader["Image loader<br/>[img_loader.py]"]
  node_ch6_assets[("Pictures<br/>bundled assets")]
end

subgraph group_motion["Motion chapters"]
  node_ch7_anim_tools["Animation tools<br/>addon scripts<br/>[action_to_range.py]"]
  node_ch8_shaker["Object shaker<br/>addon<br/>[object_shaker.py]"]
  node_ch9_pendulum["Pendulum<br/>addon<br/>[pendulum.py]"]
end

subgraph group_later["Later add-ons"]
  node_ch10_punchclock["Punch clock<br/>addon<br/>[punchclock.py]"]
  node_ch11_latte["Latte express<br/>addon<br/>[latte_express.py]"]
  node_ch12_textament["Textament<br/>addon<br/>[textament.py]"]
end

subgraph group_assets["Chapter assets"]
  node_ch8_scene[("Loop scene<br/>blend scene<br/>[ani_loop.blend]")]
  node_ch12_textures[("Textures<br/>media assets")]
end

node_ch1_script -->|"uses"| node_blender_api
node_ch2_examples -->|"reads/writes"| node_blender_api
node_ch3_entry -->|"registers with"| node_blender_api
node_ch3_simple_addon -->|"operates on"| node_blender_api
node_ch4_floor_transform -->|"operates on"| node_blender_api
node_ch5_panel -->|"extends UI"| node_blender_api
node_ch6_package -->|"registers with"| node_blender_api
node_ch6_package -->|"loads"| node_ch6_ops
node_ch6_package -->|"loads"| node_ch6_panel
node_ch6_package -->|"loads"| node_ch6_objects_panel
node_ch6_package -->|"loads"| node_ch6_prefs
node_ch6_package -->|"loads"| node_ch6_loader
node_ch6_loader -->|"reads"| node_ch6_assets
node_ch6_panel -->|"invokes"| node_ch6_ops
node_ch6_objects_panel -->|"invokes"| node_ch6_ops
node_ch6_prefs -->|"configures"| node_blender_api
node_ch7_anim_tools -->|"animates"| node_blender_api
node_ch8_shaker -->|"updates"| node_blender_api
node_ch8_shaker -->|"uses scene"| node_ch8_scene
node_ch9_pendulum -->|"drives motion"| node_blender_api
node_ch10_punchclock -->|"registers with"| node_blender_api
node_ch11_latte -->|"registers with"| node_blender_api
node_ch12_textament -->|"registers with"| node_blender_api
node_ch12_textament -->|"uses"| node_ch12_textures

click node_ch1_script "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch1/OurFirstScript.py"
click node_ch2_examples "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch2/0300_accessing_blender_modules.py"
click node_ch3_simple_addon "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch3/addons/object_collector.py"
click node_ch3_entry "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch3/the_simplest_add_on.py"
click node_ch4_floor_transform "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch4/addons/object_floor_transform.py"
click node_ch5_panel "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch5/addons/very_simple_panel.py"
click node_ch6_package "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/__init__.py"
click node_ch6_ops "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/operators.py"
click node_ch6_panel "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/panel.py"
click node_ch6_objects_panel "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/objects_panel.py"
click node_ch6_prefs "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/preferences.py"
click node_ch6_loader "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/img_loader.py"
click node_ch6_assets "https://github.com/packtpublishing/python-scripting-in-blender/tree/main/ch6/addons/structured_addon/pictures"
click node_ch7_anim_tools "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch7/addons/action_to_range.py"
click node_ch8_scene "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch8/_scenes_/ani_loop.blend"
click node_ch8_shaker "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch8/addons/object_shaker.py"
click node_ch9_pendulum "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch9/addons/pendulum.py"
click node_ch10_punchclock "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch10/addons/punchclock.py"
click node_ch11_latte "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch11/addons/latte_express.py"
click node_ch12_textament "https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch12/addons/textament.py"
click node_ch12_textures "https://github.com/packtpublishing/python-scripting-in-blender/tree/main/ch12/_media_/textures"

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_blender_api,node_ch8_scene,node_ch12_textures toneBlue
class node_ch1_script,node_ch2_examples toneAmber
class node_ch3_simple_addon,node_ch3_entry,node_ch4_floor_transform,node_ch5_panel toneMint
class node_ch6_package,node_ch6_ops,node_ch6_panel,node_ch6_objects_panel,node_ch6_prefs,node_ch6_loader,node_ch6_assets toneRose
class node_ch7_anim_tools,node_ch8_shaker,node_ch9_pendulum toneIndigo
class node_ch10_punchclock,node_ch11_latte,node_ch12_textament toneTeal
```

## Components

### Blender platform

The Blender runtime, data model, operators, UI, and add-on lifecycle that all examples target.

- **Blender API**: runtime/bpy · Blender’s Python environment, scene/object data, operators, UI, and registration APIs.

### Early chapters

Introductory scripts and first add-on examples.

- [First script](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch1/OurFirstScript.py): procedural script · A basic entry-level Blender Python script. · `ch1/OurFirstScript.py`
- [Context basics](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch2/0300_accessing_blender_modules.py): script examples · A small set of scripts showing Blender modules, data access, and user context. · `ch2/0300_accessing_blender_modules.py`

### Add-on chapters

Chapters focused on operators, panels, and registered add-ons.

- [Simple add-on](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch3/addons/object_collector.py): addon · Early transition from script-only logic to a registered Blender add-on. · `ch3/addons/object_collector.py`
- [Addon start](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch3/the_simplest_add_on.py): addon entry · The simplest add-on entry point used to introduce registration patterns. · `ch3/the_simplest_add_on.py`
- [Floor transform](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch4/addons/object_floor_transform.py): addon operator · An add-on example focused on object transformation logic. · `ch4/addons/object_floor_transform.py`
- [Simple panel](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch5/addons/very_simple_panel.py): ui addon · A minimal add-on that introduces Blender UI panels. · `ch5/addons/very_simple_panel.py`

### Structured add-on

The chapter 6 package that splits an add-on into multiple modules and resources.

- [Structured addon](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/__init__.py): addon package · The main multi-module add-on example with clear internal separation of concerns. · `ch6/addons/structured_addon/__init__.py`
- [Operators](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/operators.py): module · Operator logic for the structured add-on. · `ch6/addons/structured_addon/operators.py`
- [Main panel](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/panel.py): module · Primary UI panel for the structured add-on. · `ch6/addons/structured_addon/panel.py`
- [Objects panel](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/objects_panel.py): module · Secondary panel focused on object-related UI. · `ch6/addons/structured_addon/objects_panel.py`
- [Preferences](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/preferences.py): module · Add-on preferences and configuration state. · `ch6/addons/structured_addon/preferences.py`
- [Image loader](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch6/addons/structured_addon/img_loader.py): module · Asset-loading helper for bundled images. · `ch6/addons/structured_addon/img_loader.py`
- [Pictures](https://github.com/packtpublishing/python-scripting-in-blender/tree/main/ch6/addons/structured_addon/pictures): bundled assets · Packaged images used by the structured add-on. · `ch6/addons/structured_addon/pictures`

### Motion chapters

Examples centered on animation, time-based behavior, and motion control.

- [Animation tools](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch7/addons/action_to_range.py): addon scripts · Animation- and motion-oriented add-ons and utilities. · `ch7/addons/action_to_range.py`
- [Object shaker](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch8/addons/object_shaker.py): addon · A time-based motion example that likely drives object movement and updates. · `ch8/addons/object_shaker.py`
- [Pendulum](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch9/addons/pendulum.py): addon · An animation-oriented example using Blender motion and timing. · `ch9/addons/pendulum.py`

### Later add-ons

Standalone add-ons in the final chapters.

- [Punch clock](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch10/addons/punchclock.py): addon · A standalone later-chapter add-on example. · `ch10/addons/punchclock.py`
- [Latte express](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch11/addons/latte_express.py): addon · A later-chapter standalone add-on example. · `ch11/addons/latte_express.py`
- [Textament](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch12/addons/textament.py): addon · A final-chapter add-on example with bundled media. · `ch12/addons/textament.py`

### Chapter assets

Bundled scene and media files used by the examples.

- [Loop scene](https://github.com/packtpublishing/python-scripting-in-blender/blob/main/ch8/_scenes_/ani_loop.blend): blend scene · A sample Blender scene file used as chapter input data. · `ch8/_scenes_/ani_loop.blend`
- [Textures](https://github.com/packtpublishing/python-scripting-in-blender/tree/main/ch12/_media_/textures): media assets · Packaged texture assets supporting the final chapter add-on. · `ch12/_media_/textures`

## Connections

- First script → Blender API: uses · Runs as a Blender script and directly mutates scene state.
- Context basics → Blender API: reads/writes · Demonstrates module access, data access, and user context inside Blender.
- Addon start → Blender API: registers with · Introduces add-on registration in Blender.
- Simple add-on → Blender API: operates on · Collects or manipulates objects through Blender data and operators.
- Floor transform → Blender API: operates on · Applies object transform logic through Blender APIs.
- Simple panel → Blender API: extends UI · Adds a Blender panel to expose add-on actions.
- Structured addon → Blender API: registers with · Package entry point integrates the structured add-on into Blender.
- Structured addon → Operators: loads · Initializes operator definitions as part of the package.
- Structured addon → Main panel: loads · Initializes the main UI panel module.
- Structured addon → Objects panel: loads · Initializes the object-specific UI module.
- Structured addon → Preferences: loads · Initializes add-on preferences.
- Structured addon → Image loader: loads · Initializes image-loading support.
- Image loader → Pictures: reads · Loads bundled pictures used by the add-on.
- Main panel → Operators: invokes · UI triggers operator actions.
- Objects panel → Operators: invokes · Object-focused UI triggers operators.
- Preferences → Blender API: configures · Uses Blender’s preference and registration mechanisms.
- Animation tools → Blender API: animates · Works with actions, ranges, and motion-related Blender data.
- Object shaker → Blender API: updates · Drives object motion over time in Blender.
- Object shaker → Loop scene: uses scene · Operates against the sample animation scene.
- Pendulum → Blender API: drives motion · Implements a pendulum-style animation example.
- Punch clock → Blender API: registers with · Standalone add-on example built for Blender.
- Latte express → Blender API: registers with · Standalone add-on example built for Blender.
- Textament → Blender API: registers with · Final add-on example built for Blender.
- Textament → Textures: uses · Relies on bundled texture/media assets.
