Geometry Nodes Modifier not updating mesh when input set with python

I’m setting the inputs of a GeometryNode modifier with python, e.g:

obj.modifiers["GeometryNodes"]["Socket_16"] = 4

The input in question is of type ‘Menu’.

Nothing happens. If I then mouse over the modifier stack, the value of the input updates, but the mesh does not change as it is expected to. If I then click the input and rechose the value that’s already seemingly slelected, the mesh updates.

I did see mention of this before when I was looking into using geometry nodes, and have placed:

bpy.context.view_layer.update()

At the end of my code which was recommended, but it’s not doing anything for me.

I also tried:

obj.modifiers["GeometryNodes"].node_group.nodes["Group Output.001"].update()

How can I force it to update correctly?

Okay as per this (https://projects.blender.org/blender/blender/issues/87006) I was able to at least get it working with

obj = bpy.context.object

...

obj.update_tag()
bpy.data.scenes['Scene'].frame_current = bpy.data.scenes['Scene'].frame_current+1

Not sure if there is a proper way of doing this but seems to be okay for now.

According to the report you linked If you’re using Blender 4.0+ you can use mod.node_group.interface_update(bpy.context).

obj.data.update() also seems to work :slight_smile: