python - Blender scale value not updating -
when run script:
import bpy import math s = bpy.context.scene.frame_start e = bpy.context.scene.frame_end values = [] print(s) print(e) in range(s,e): bpy.context.scene.frame_current = print(i) v = (bpy.context.object.scale[1]) bpy.context.object.scale[0] = print('at frame ',str(i), ' value ' ,str(v)) values.extend([bpy.context.object.scale[1]])
it gives me right number of frames, value same, if scale[1] of object baked sound, change between frames.
it looks blender doesn't update value , take value of frame during text ran.
any way update value during running of code in real time?
you looking @ wrong values.
you have v = scale[1]
set scale[0] = i
, print(v)
reading scale.y , changing scale.x looking @ scale.y
it better use scene.frame_set()
change frames via python.
another approach getting keyed value use fcurve.evaluate(frame)
import bpy s = bpy.context.scene.frame_start e = bpy.context.scene.frame_end values = [] f = bpy.context.object.animation_data.action.fcurves.find('scale', index=1) in range(s,e): v = f.evaluate(i) print('at frame ',str(i), ' value ' ,str(v)) values.extend([v])
and if planning keyframe values, don't need change frames can specify frame in keyframe_insert(data_path, frame=f)
obj.keyframe_insert('scale', frame=2) obj.keyframe_insert('scale', index=1, frame=5) # key scale.y