1
$\begingroup$

I need drivers and properties to be changed at the same time via my script. But the drivers are not updated after I press the "Run" button. struct After a property has been changed with a script, how do I force update all drivers?

Edit:
I completely forgot to mention that I have nested drivers. Code bpy.context.view_layer.update() successfully updates everything, but nested drivers are updated with 80% success rate.

$\endgroup$
3
  • $\begingroup$ You sure have many many things in the script. :D 9 of them... that's a lot. $\endgroup$ Mar 8, 2023 at 18:17
  • 1
    $\begingroup$ You might need multiple updates. $\endgroup$ Mar 8, 2023 at 18:40
  • $\begingroup$ @MartynasŽiemys Cool, multiple updates solved the problem. Thank you. $\endgroup$
    – ugorek
    Mar 8, 2023 at 18:43

1 Answer 1

0
$\begingroup$

bpy.context.view_layer.update() should do it.

See: https://docs.blender.org/api/current/info_gotcha.html#stale-data

$\endgroup$
4
  • $\begingroup$ It works successfully with a 80% chance. Sometimes you have to click on the script button twice to update everything. $\endgroup$
    – ugorek
    Mar 8, 2023 at 18:16
  • $\begingroup$ @ugorek, could you give an example where it doesn't work? $\endgroup$ Mar 8, 2023 at 18:21
  • $\begingroup$ Python script changes rotations of an object (light). The driver for rotating an object along the z axis changes the sun rotation of the "Sky Texture" node in "World". The code bpy.context.view_layer.update() successfully updates the driver at 80% chance when the Run button is clicked. $\endgroup$
    – ugorek
    Mar 8, 2023 at 18:24
  • 1
    $\begingroup$ Could you maybe share the code? You could edit the question and include it there. $\endgroup$ Mar 8, 2023 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .