baldingwizard / Blender-Addons

119 stars 20 forks source link

Not working as expected in 4.0 stable #18

Open Syndaryl opened 8 months ago

Syndaryl commented 8 months ago

Dynamic Maths Expressions (Paid version) hasn't survived the change to 4.0 unscathed. If I try to create an instance of the Test script, it creates an empty geometry group with no inputs or outputs, and the status bar shows the following error:

Build of node tree failed : 'GeometryNodeTree' object has no attribute 'outputs'

while the console shows

Error: Python: Traceback (most recent call last):
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\MathsExpressionBlender28\dynamic_maths_expression_node.py", line 2740, in execute
    bpy.ops.text.jump({"area":newarea}, line=1)
  File "D:\Blender\stable\blender-4.0.0-windows-x64\4.0\scripts\modules\bpy\ops.py", line 106, in __call__
    C_exec, C_undo = _BPyOpsSubModOp._parse_args(args)
  File "D:\Blender\stable\blender-4.0.0-windows-x64\4.0\scripts\modules\bpy\ops.py", line 60, in _parse_args
    raise ValueError("1-2 args execution context is supported")
ValueError: 1-2 args execution context is supported

Left expressionText un-decoded!
validating expression represented by ',(inputs(variable(val1),,(variable(val2),,(variable(val3),,(variable(vec1),,(variable(vec2),variable(vec3)))))),,(=(variable(Add),+(variable(val1),variable(val2))),,(=(variable(Subtract),-(variable(val1),variable(val2))),,(=(variable(Multiply),*(variable(val1),variable(val2))),,(=(variable(Divide),/(variable(val1),variable(val2))),,(=(variable(Power),**(variable(val1),variable(val2))),,(=(variable(Log),log(variable(val1),variable(val2))),,(=(variable(Sine),sin(variable(val1))),,(=(variable(Cosine),cos(variable(val1))),,(=(variable(Trangent),tan(variable(val1))),,(=(variable(Arcsine),asin(variable(val1))),,(=(variable(Arccosine),acos(variable(val1))),,(=(variable(Arctangent),atan(variable(val1))),,(=(variable(Arctangent2),-(value(1.5707963),+(atan(/(variable(val2),variable(val1))),*(<(variable(val1),value(0.0)),value(3.14159265))))),,(=(variable(Modulo),mod(variable(val1),variable(val2))),,(=(variable(Absolute),abs(variable(val1))),,(=(variable(Max),max(variable(val1),variable(val2))),,(=(variable(MultiMax),max(variable(val1),,(variable(val2),variable(val3)))),,(=(variable(Min),min(variable(val1),variable(val2))),,(=(variable(MultiMin),min(variable(val1),,(variable(val2),variable(val3)))),,(=(variable(Greater),>(variable(val1),variable(val2))),,(=(variable(GreaterEqual),-(value(1),<(variable(val1),variable(val2)))),,(=(variable(Less),<(variable(val1),variable(val2))),,(=(variable(LessEqual),-(value(1),>(variable(val1),variable(val2)))),,(=(variable(Equal),-(value(1.0),>(abs(-(variable(val1),variable(val2))),value(0)))),,(=(variable(NotEqual),<(variable(val1),>(,variable(val2)))),,(=(variable(NotEqual2),<(variable(val2),>(,variable(val2)))),,(=(variable(VectorAdd),vadd(variable(vec1),variable(vec2))),,(=(variable(VectorSubtract),vsub(variable(vec1),variable(vec2))),,(=(variable(VectorMultiply),vmult(variable(vec1),variable(vec2))),,(=(variable(VectorDivide),vdiv(variable(vec1),variable(vec2))),=(variable(Colorramp),colorramp(variable(val1),,(value(0),,(combine(value(0),,(value(0),value(0))),,(value(0.25),,(combine(value(1),,(value(0),value(0))),,(value(0.5),,(combine(value(0),,(value(1),value(0))),,(value(0.75),,(combine(value(0),,(value(0),value(1))),,(value(1.0),combine(value(0),value(0.0))))))))))))))))))))))))))))))))))))))))))))'
Traceback (most recent call last):
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\MathsExpressionBlender28\dynamic_maths_expression_node.py", line 2122, in execute_main
    self.__nodeinterface_setup__()
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\MathsExpressionBlender28\dynamic_maths_expression_node.py", line 461, in __nodeinterface_setup__
    if len(self.node_tree.outputs) < 1:
AttributeError: 'GeometryNodeTree' object has no attribute 'outputs'

various errors occur with other use cases as well.

Syndaryl commented 8 months ago

Creating a script to calculate theta=atan2(Input[y],Input[x]),phi=acos(input[z]) produces

Python: Traceback (most recent call last):
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 158, in execute
    self.parse_expressions(scene.custom_expression_nodes_props)
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 148, in parse_expressions
    module = ast.parse(props.expression)
  File "D:\Blender\stable\blender-4.0.0-windows-x64\4.0\python\lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    theta=atan2(Input[y],Input[x]),phi=acos(input[z])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

In this case, the same error is output to console.

Syndaryl commented 8 months ago

Just inputting atan2(Input[y],Input[x]) produces:

Python: Traceback (most recent call last):
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 158, in execute
    self.parse_expressions(scene.custom_expression_nodes_props)
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 150, in parse_expressions
    root = self.create_nodes(expression.value, self.init_position)
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 145, in create_nodes
    return creator(value, location)
  File "C:\Users\Owner\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\expression-nodes.py", line 115, in create_call
    self.node_tree.links.new(node.inputs[idx], arg.outputs[0])
AttributeError: 'NoneType' object has no attribute 'outputs'
baldingwizard commented 8 months ago

Hi. Thanks for reporting these issues - I've not had time recently to keep up with this and so hadn't tried it against the latest release. I'll have a look when I get the chance and see if I can spot the issue. Presumably Blender 4.0 has some API changes that have caused the problems; I did manage to test it on 3.6 and that seems to be OK.... I'll let you know what I find and when an update is available.

Syndaryl commented 8 months ago

No problem, 4.0 is a pretty big release and there's been a lot of work in and around Geometry Nodes. In particular the way node groups inputs and outputs are wrangled has definitely changed quite a bit in the GUI, so there's probably related changes under the hood.

I use the addon pretty extensively in 3.6 and haven't had any issues, so it's something that's shifted for 4.0

DarioDaF commented 2 months ago

Ignoring the parsing error above the culprit seems to be the code working on a the node tree instead of the group object:

D.materials['Material'].node_tree.nodes[9].bl_idname # 'ShaderNodeGroup'
D.materials['Material'].node_tree.nodes[9].node_tree.bl_idname # 'ShaderNodeTree'

The group does have outputs collection while the node_tree associated to it does not (probably because it can be the root tree too).

Going into the tree from the group node is as shown above pretty straightforward, the other way around probably requires various changes that at the moment I don't have time to contribute, in case this changes I'll let you know