Build nodes trees in Blender more elegantly with code
Project description
nodebpy
Build node trees in Blender more elegantly with Python code. Geometry Nodes, Shader Nodes and Compositor nodes are all fully supported, with type hints and IDE auto-completion throughout.
pip install nodebpy
A text-based version of nodes should bring the convenience of writing code with IDE auto-completion, type hinting, with overall compactness and readability, while staying as close as possible to what building a node tree via the GUI feels like.
from nodebpy import geometry as g
with g.tree("AnotherTree", collapse=True) as tree:
rotation = (
g.RandomValue.vector(min=-1, seed=2)
>> g.AlignRotationToVector()
>> g.RotateRotation(rotate_by=g.AxisAngleToRotation(angle=0.3))
)
_ = (
tree.inputs.integer("Count", 10)
>> g.Points(position=g.RandomValue.vector(min=-1))
>> g.InstanceOnPoints(instance=g.Cube(), rotation=rotation)
>> g.SetPosition(
position=g.Position() * 2.0 + (0, 0.2, 0.3),
offset=(0, 0, 0.1),
)
>> g.RealizeInstances()
>> g.InstanceOnPoints(g.Cube(), instance=...)
>> tree.outputs.geometry("Instances")
)
- Every node is a typed class named after the node it creates — 'Random Value' becomes
g.RandomValue()— and node subtypes are class methods:g.RandomValue.vector(). - Trees are built inside a
with g.tree(...):context; instantiating a node class adds it to the current tree, and the tree's interface is declared withtree.inputs.*/tree.outputs.*. - Nodes are linked with the
>>operator, which picks the most compatible socket pair automatically (much like Node Wrangler's Alt + Right Click drag) — or address sockets explicitly through the.i.*/.o.*accessors. - Python's arithmetic, comparison and boolean operators create the matching
Math/VectorMath/Compare/BooleanMathnodes:g.Value(1.0) * 2 + (0, 0, 1). - Existing node trees — including ones wired up by hand in the GUI — can be exported back to
nodebpysource withto_python().
Documentation
Guides and the full node reference live at bradyajohnston.github.io/nodebpy:
- Writing node trees — adding, linking and organising nodes
- Math operators — arithmetic, comparison and boolean expressions as nodes
- Node API design — sockets, accessors, enum options and class methods
- Custom node groups and asset node groups — reusable groups as Python classes
- Nodes to code — turn existing trees back into
nodebpycode - Using
nodebpyin your add-on — installation, bundling and the Blender-tracking versioning scheme - Comparisons — how the API relates to
geometry-script,geonodes, NodeToPython and TreeClipper
Like databpy, this project started as an internal tool inside molecularnodes before being broken out into its own robustly typed and tested package.
Contributing
Development setup, running the tests and regenerating the node classes (most of src/nodebpy/nodes/ is auto-generated by the gen/ package) are covered in CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nodebpy-520.5.2.tar.gz.
File metadata
- Download URL: nodebpy-520.5.2.tar.gz
- Upload date:
- Size: 298.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a041d416b25588fac070c47a28690962d68eda77dc54ad5f547633f60355d0a
|
|
| MD5 |
e0668d6e5d46c09cfb49a6af82551aec
|
|
| BLAKE2b-256 |
da8477fb7887f6a5bc7537dd928fc69850af069978fb6663839f3b44c14bf7a4
|
Provenance
The following attestation bundles were made for nodebpy-520.5.2.tar.gz:
Publisher:
pypi.yml on BradyAJohnston/nodebpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nodebpy-520.5.2.tar.gz -
Subject digest:
2a041d416b25588fac070c47a28690962d68eda77dc54ad5f547633f60355d0a - Sigstore transparency entry: 2100851742
- Sigstore integration time:
-
Permalink:
BradyAJohnston/nodebpy@902ec9fee333de465589635848f5a3e163cc271b -
Branch / Tag:
refs/tags/v520.5.2 - Owner: https://github.com/BradyAJohnston
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@902ec9fee333de465589635848f5a3e163cc271b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nodebpy-520.5.2-py3-none-any.whl.
File metadata
- Download URL: nodebpy-520.5.2-py3-none-any.whl
- Upload date:
- Size: 338.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d15328bb473d6fef65a01b97c1c7c458c4e5519bfc97c6377bcd0425a6a47a1
|
|
| MD5 |
61d8396d2d5b9a59ef4cc8fc79d2f794
|
|
| BLAKE2b-256 |
7a39feb7b7d4473a01e68bf7712fffec63a8a9c4d74fa3a8a26698582bf3ec17
|
Provenance
The following attestation bundles were made for nodebpy-520.5.2-py3-none-any.whl:
Publisher:
pypi.yml on BradyAJohnston/nodebpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nodebpy-520.5.2-py3-none-any.whl -
Subject digest:
8d15328bb473d6fef65a01b97c1c7c458c4e5519bfc97c6377bcd0425a6a47a1 - Sigstore transparency entry: 2100851969
- Sigstore integration time:
-
Permalink:
BradyAJohnston/nodebpy@902ec9fee333de465589635848f5a3e163cc271b -
Branch / Tag:
refs/tags/v520.5.2 - Owner: https://github.com/BradyAJohnston
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@902ec9fee333de465589635848f5a3e163cc271b -
Trigger Event:
push
-
Statement type: