5
$\begingroup$

I copied full datapath for my property Vertices X as shown below and set it via python using bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Socket_2"] = 5. The value will update when you hover over it but it does not update the 3D View evidenced in the GN tree socket value it's still 2 instead of 5. Why? I found this thread but no answer. Is this a bug?

I also tried context.view_layer.update() but that didn't help...

enter image description here

I noticed that when I manually toggle back and forth it works but if I do it with script it doesn't:

bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Socket_2"] = 5
bpy.ops.object.mode_set_toggle()
bpy.ops.object.mode_set_toggle()

I also found this answer and tried this:

dg = bpy.context.evaluated_depsgraph_get()
dg.update() 

But that also doesn't work. Is this maybe a bug I should log?

$\endgroup$

1 Answer 1

5
$\begingroup$

You can do the following:

import bpy

cube = bpy.data.objects["Cube"]

cube.modifiers["GeometryNodes"]["Socket_2"] = 2

cube.modifiers.update()

cube.update_tag()

About cube.modifiers.update() the Python console says

update() .. method:: update() Execute the properties update callback. .. note:: This is called when assigning a property, however in rare cases it's useful to call explicitly.

$\endgroup$
0

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.