1
$\begingroup$

Each one of the following scripts (which provide different collections as input for the Geometry-Node) work as expected on their own and output different values:

Script 1 (Isometric Reference Collection) :

import bpy

from bpy import data as D
from bpy import context as C  
     

# specify input for Geometry Node (i.e. collection):
D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Reference Collection"]

# retrieve comptuted output (via Named-Attribute) from Geometry Node 
H_REF = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
    .data.attributes["H_MAX"].data[0].value

print("H_REF = " + str(H_REF))

Script 2 (Isometric Render Collection):

import bpy

from bpy import data as D
from bpy import context as C  
     

# specify input for Geometry Node (i.e. collection):
D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Render Collection"]

# retrieve comptuted output (via Named-Attribute) from Geometry Node 
H_MAX = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
    .data.attributes["H_MAX"].data[0].value

print("H_MAX = " + str(H_MAX))

However, I need both values H_REF and H_MAX in a single script, but if I combine the two above scripts to a single one then both values are the same.

Script 3 (evaluating both collections):

import bpy

from bpy import data as D
from bpy import context as C  
     

# specify input for Geometry Node (i.e. collection):
D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Reference Collection"]

# retrieve comptuted output (via Named-Attribute) from Geometry Node 
H_REF = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
    .data.attributes["H_MAX"].data[0].value

print("H_REF = " + str(H_REF))

# specify input for Geometry Node (i.e. collection):
D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Render Collection"]

# retrieve comptuted output (via Named-Attribute) from Geometry Node 
H_MAX = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
    .data.attributes["H_MAX"].data[0].value

print("H_MAX = " + str(H_MAX))

I just could duplicate the corresponding Geometry-Node with providing specific collections, but how to fix this via Python, any ideas (I use blender version 3.4)?

$\endgroup$
3

1 Answer 1

1
$\begingroup$

After some research I finally found a similar problem here Evaluate a geometry node tree in python
As we assumed, it is some update or evaluation issue.
The given workoround also works for me, i.e. setting a new input-value for a Geometry-Node Group needs an update in order to take effect immediately:

bpy.data.objects["Result Object"].update_tag()

So adjusting Script 3 results in the following workaround with different output values:

D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Reference Collection"]
# needs update:
D.objects["Floor Plane"].update_tag()
H_REF = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
.data.attributes["H_MAX"].data[0].value

print("H_REF = " + str(H_REF))

D.objects["Floor Plane"].modifiers["GeometryNodes"]["Input_15"]\
    = D.collections["Isometric Render Collection"]
# needs update:
D.objects["Floor Plane"].update_tag()
H_MAX = D.objects["Floor Plane"].evaluated_get(C.evaluated_depsgraph_get())\
    .data.attributes["H_MAX"].data[0].value

print("H_MAX = " + str(H_MAX))
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .