I have created an object using geometry nodes. I control its input node "String." I want to control the position of this object based on the x dimension, but when I change the string (therefore, the dimensions of the object), it does not update immediately. Instead, it keeps the location of the previous string, and only when I rerun the script again, the object moves to the correct position.
import bpy
Texts = bpy.data.collections["Texts"].objects
bpy.data.node_groups["Geometry Nodes"].nodes["String"].string = 'The Text I Want To Change'
Texts[0].location[0] = 0 - Texts[0].dimensions.x/2
bpy.context.view_layer.update()
$\endgroup$