1

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.

barakooda
  • 183
  • 7
  • I think you want 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
  • Thanks Marty but I already mentioned bpy.context.view_layer.update() I also mentioned when it does work. Generally things are not consistent and its frustrating. tried also all the other mambo jambo hacks. – barakooda Jun 03 '22 at 07:54
  • In that case I suspect that you have hit a bug and might consider filing a bug report. – Marty Fouts Jun 03 '22 at 13:14

0 Answers0