diff --git a/book/src/api/advanced-scripting/node-groups.md b/book/src/api/advanced-scripting/node-groups.md index 476c934..025f43b 100644 --- a/book/src/api/advanced-scripting/node-groups.md +++ b/book/src/api/advanced-scripting/node-groups.md @@ -22,4 +22,25 @@ The *Instance Grid* node group uses the passed in `instance` argument to create ![](./instance_grid.png) -This concept can scale to complex interconnected node trees, while keeping everything neatly organized in separate functions. \ No newline at end of file +This concept can scale to complex interconnected node trees, while keeping everything neatly organized in separate functions. + +## Functions vs Node Groups + +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. + +```python +def instance_grid(instance: Geometry): # Not marked with `@tree(...)` + return grid().mesh_to_points().instance_on_points(instance=instance) + +@tree("Cube Grid") +def cube_grid(): # Marked with `@tree(...)` + return instance_grid(instance=cube(size=0.2)) +``` + +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: + +```python +@tree("Cube Grid") +def cube_grid(): + return grid().mesh_to_points().instance_on_points(instance=cube(size=0.2)) +``` \ No newline at end of file