kopia lustrzana https://github.com/carson-katri/geometry-script
Add scripted_expression helper function
rodzic
1cdd975dbf
commit
7001a179c0
book/src
api/advanced-scripting
|
@ -30,6 +30,8 @@ def build_node(node_type):
|
|||
value = value.value
|
||||
setattr(node, prop.identifier, value)
|
||||
for node_input in (node.inputs[1:] if _primary_arg is not None else node.inputs):
|
||||
if not node_input.enabled:
|
||||
continue
|
||||
argname = node_input.name.lower().replace(' ', '_')
|
||||
all_with_name = []
|
||||
for node_input2 in (node.inputs[1:] if _primary_arg is not None else node.inputs):
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
def scripted_expression(scripted_expression: str) -> 'Type':
|
||||
from geometry_script import Type, State
|
||||
value_node = State.current_node_tree.nodes.new('ShaderNodeValue')
|
||||
fcurve = value_node.outputs[0].driver_add("default_value")
|
||||
fcurve.driver.expression = scripted_expression
|
||||
return Type(value_node.outputs[0])
|
|
@ -8,6 +8,7 @@ from .state import State
|
|||
from .types import *
|
||||
from .node_mapper import *
|
||||
from .static.input_group import *
|
||||
from .static.expression import *
|
||||
|
||||
def _as_iterable(x):
|
||||
try:
|
||||
|
|
|
@ -38,6 +38,8 @@ class Type(metaclass=_TypeMeta):
|
|||
tuple: ('FunctionNodeInputVector', 'vector'),
|
||||
float: ('ShaderNodeValue', None),
|
||||
}
|
||||
if type(value) == int:
|
||||
print("Making an integer node?")
|
||||
if not type(value) in input_nodes:
|
||||
raise Exception(f"'{value}' cannot be expressed as a node.")
|
||||
input_node_info = input_nodes[type(value)]
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
- [Input Groups](./api/advanced-scripting/input-groups.md)
|
||||
- [Attributes](./api/advanced-scripting/attributes.md)
|
||||
- [Boolean Math](./api/advanced-scripting/boolean-math.md)
|
||||
- [Drivers](./api/advanced-scripting/drivers.md)
|
||||
|
||||
# Tutorials
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# Drivers
|
||||
|
||||
Drivers can be used with geometry nodes. To create a scripted expression driver, use the `scripted_expression` convenience function.
|
||||
|
||||
This can be used to get information like the current frame number in a Geometry Script.
|
||||
|
||||
```python
|
||||
frame_number = scripted_expression("frame")
|
||||
frame_number_doubled = scripted_expression("frame * 2")
|
||||
```
|
Ładowanie…
Reference in New Issue