Add note about functions vs trees to node groups page

pull/10/head
Carson Katri 2022-11-20 18:09:08 -05:00
rodzic 391d74ec61
commit a360f26fde
1 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -23,3 +23,24 @@ 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.
## 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))
```