how to update the dpendency graph after switching a scene? after i`m open the file I see the switching was successful but during the code it does not change.
I think to change frame number as a hack,but. there is any official non hackish way to do it ?
scene = bpy.data.scenes.get(self.data.scene_name)
result : <bpy_struct, Scene("Scene") at 0x0000023020016048>
dgutils.switch_to_scene(scene)
print(bpy.context.scene)
result: <bpy_struct, Scene("Night") at 0x000002302003C088>
depsgraph = bpy.context.evaluated_depsgraph_get()
bpy.context.view_layer.update()
depsgraph.update()
print(bpy.context.scene)
result: <bpy_struct, Scene("Night") at 0x000002302003C088>
Update: Code works fine when using -background from cmd otherwise the dependency graph not update.
bpy.context.view_layer.update()but see this answer and comments for an alternative that suggests your approach should work. Are you getting any error messages? – Marty Fouts Jun 02 '22 at 17:09