I've a script that starts render animation from frame 1 to 250, I want a script that changes the current frame to 150 when it reaches 250
I'm trying to write a function that changes current frame to 150 if current frame is 250
here's my code:
def stop_playback(scene):
if scene.frame_current == 250:
bpy.ops.screen.animation_cancel(restore_frame=False)
bpy.app.handlers.frame_change_pre.append(stop_playback)
bpy.ops.screen.animation_play()
def change_frame():
if scene.frame_current == 250:
bpy.data.scenes["Scene"].frame_set(150)
change_frame()
here's my console output:
>>> def change_frame():
... if scene.frame_current == 250:
... bpy.data.scenes["Scene"].frame_set(150)
...
>>> change_frame()
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "<blender_console>", line 2, in change_frame
NameError: name 'scene' is not defined
def change_frame():
. And also,scene
is not a references at that function. Thescene
in other function block should not be called here. You might want to pass that value as a parameter inside the parenthesesdef change_frame(scene_at_this_function):
. $\endgroup$