I have a simple script like this:
import bpy
frame = 0
def tester(scene):
global frame
frame = scene.frame_current
print(frame)
bpy.app.handlers.frame_change_pre.append(tester)
It should print out the current frame. If I just play the animation, works as expected, but when I start rendering it gives back multiple numbers on each frame.
(I'm only using this script to demonstrate, the problem is occurring in a more complex script. But the anomaly is the same.)
I'm getting results during rendering like this:
1
0
1
1
Saved: 'C:\......'
2
1
2
2
Saved: 'C:\......'
3
2
3
3
Saved: 'C:\......'
and so on...
Any guess why and how can I prevent this from happening? (I'm trying to insert an if statement that is prevening the recalculation of an already calculated frame, but this solution is way more hacky than it should be...)