Skip to content

Commit 3c791c1

Browse files
rename added group node (#127)
1 parent c7f7a7c commit 3c791c1

8 files changed

Lines changed: 43 additions & 4 deletions

File tree

docs/_variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 520.7.0
1+
version: 520.8.0

docs/changelog.qmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
title: Changelog
33
---
44

5+
## v520.8.0 - 2026-07-17
6+
7+
### Enhancements
8+
- **Group nodes are named after their tree** — adding a custom node group (`CustomGeometryGroup` / `CustomShaderGroup` / `CustomCompositorGroup`, including asset-backed groups) now names the group *node* after its node tree (e.g. `Smooth by Angle`, `Smooth by Angle.001`) instead of Blender's default `Group` / `Group.001`, matching how group assets are named when added from the Add menu.
9+
510
## v520.7.0 - 2026-07-16
611

712
### Enhancements

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "nodebpy"
3-
version = "520.7.0"
3+
version = "520.8.0"
44
description = "Build nodes trees in Blender more elegantly with code"
55
readme = "README.md"
66
authors = [

src/nodebpy/builder/node.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ def __init__(self, **kwargs):
387387
self._establish_links(**kwargs)
388388
if named_links:
389389
self._establish_named_links(named_links)
390+
# Name the node after its tree (Blender deduplicates with a
391+
# ``.001``-style suffix), matching how group assets added from the
392+
# Add menu are named, instead of Blender's default ``Group``.
393+
self.node.name = self.node_tree.name
390394

391395
@property
392396
@abstractmethod

tests/__snapshots__/test_codegen.ambr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
# Restore authored node positions.
170170
tree.node_positions = {
171171
"Group Input": (0.0, 0.0),
172-
"Group": (120.0, 50.0),
172+
"SnapInner": (120.0, 50.0),
173173
"Group Output": (240.0, 100.0),
174174
}
175175
'''

tests/test_assets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_generated_asset_appends_and_links():
7070
node = ng.SmoothByAngle(mesh=ng.Cube(), angle=0.5)
7171
assert node.node.node_tree is not None
7272
assert node.node.node_tree.name == "Smooth by Angle"
73+
assert node.node.name == "Smooth by Angle"
7374
assert node.o.mesh is not None
7475
assert any(socket.is_linked for socket in node.node.inputs)
7576

tests/test_custom_groups.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,35 @@ def test_group_reuses_existing_node_group():
216216
assert a.node is not b.node
217217

218218

219+
# --- Node naming ---
220+
221+
222+
def test_group_node_named_after_tree():
223+
"""The group node is named after its node tree, not Blender's default
224+
'Group', matching how assets added from the Add menu are named."""
225+
with TreeBuilder():
226+
geom = _SimpleGeomGroup()
227+
assert geom.node.name == "Test Simple Geometry Group"
228+
229+
with TreeBuilder.shader():
230+
shader = _SimpleShaderGroup()
231+
assert shader.node.name == "Test Simple Shader Group"
232+
233+
with TreeBuilder.compositor():
234+
comp = _SimpleCompositorGroup()
235+
assert comp.node.name == "Test Simple Compositor Group"
236+
237+
238+
def test_group_node_name_deduplicated():
239+
"""Repeated instances in one tree get Blender's .001-style suffixes."""
240+
with TreeBuilder():
241+
a = _SimpleGeomGroup()
242+
b = _SimpleGeomGroup()
243+
244+
assert a.node.name == "Test Simple Geometry Group"
245+
assert b.node.name == "Test Simple Geometry Group.001"
246+
247+
219248
# ---------------------------------------------------------------------------
220249
# ShaderNodeGroup
221250
# ---------------------------------------------------------------------------

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)