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
    $\begingroup$ Please provide a (MINIFIED) .blend example for testing. How to upload a blend file on BSE - good practices and advice Maybe you need to e.g. update the view layer... $\endgroup$ Commented Feb 8, 2024 at 10:14
  • $\begingroup$ I will try to upload a simplified blend-file which reproduces the misbeahviour, but it will take some time ... The hint with updating the view layer is a good starting point I guess, also see this answer relating to my problem Dependency graph API changes, however neither solutions with updates of depsgraph or view layers work. $\endgroup$ Commented Feb 8, 2024 at 13:26
  • $\begingroup$ Update : below a link to a minimized blend-file to reproduce this "misbehaviour" ... <img src="https://blend-exchange.com/embedImage.png?bid=B0DSPRLB" /> $\endgroup$ Commented Feb 9, 2024 at 9:36

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.