Add scripted_expression helper function
This commit is contained in:
parent
1cdd975dbf
commit
7001a179c0
6 changed files with 22 additions and 0 deletions
|
|
@ -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):
|
||||
|
|
|
|||
6
api/static/expression.py
Normal file
6
api/static/expression.py
Normal file
|
|
@ -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)]
|
||||
|
|
|
|||
Reference in a new issue