Skip to content

Commit a360f26

Browse files
committed
Add note about functions vs trees to node groups page
1 parent 391d74e commit a360f26

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

book/src/api/advanced-scripting/node-groups.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,25 @@ The *Instance Grid* node group uses the passed in `instance` argument to create
2222

2323
![](./instance_grid.png)
2424

25-
This concept can scale to complex interconnected node trees, while keeping everything neatly organized in separate functions.
25+
This concept can scale to complex interconnected node trees, while keeping everything neatly organized in separate functions.
26+
27+
## Functions vs Node Groups
28+
29+
You do not have to mark a function with `@tree(...)`. If you don't, function calls are treated as normal in Python. No checks are made against the arguments. Any nodes created in the callee will be placed in the caller's tree.
30+
31+
```python
32+
def instance_grid(instance: Geometry): # Not marked with `@tree(...)`
33+
return grid().mesh_to_points().instance_on_points(instance=instance)
34+
35+
@tree("Cube Grid")
36+
def cube_grid(): # Marked with `@tree(...)`
37+
return instance_grid(instance=cube(size=0.2))
38+
```
39+
40+
The above example would place the *Grid*, *Mesh to Points*, and *Instance on Points* nodes in the main "Cube Grid" tree. It could be rewritten as:
41+
42+
```python
43+
@tree("Cube Grid")
44+
def cube_grid():
45+
return grid().mesh_to_points().instance_on_points(instance=cube(size=0.2))
46+
```

0 commit comments

Comments
 (0)