kopia lustrzana https://github.com/carson-katri/geometry-script
Add note about functions vs trees to node groups page
rodzic
391d74ec61
commit
a360f26fde
|
@ -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.
|
||||
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))
|
||||
```
|
Ładowanie…
Reference in New Issue