In a new project I've add a custom property to the default cube:
bpy.data.objects["Cube"]["positions"] = [4,3,2,1]
Is it possible to access this array from a driver, so that on every frame a different value is used?
If I add a driver it is possible to access a value from a fixed position:
But I'm not able to use frame to specify the index, Blender complains about the syntax:
I've also tried to use a frame handler to set a new property with the value to be used with the following Python script:
import bpy
def frame_handler(scene):
currentposition = bpy.data.objects["Cube"]["positions"][scene.frame_current % 4]
bpy.data.objects["Cube"]["currentposition"] = currentposition
print(currentposition)
bpy.app.handlers.frame_change_pre.clear()
bpy.app.handlers.frame_change_pre.append(frame_handler)
The code is executed every time the frame position is changed and the value is set to the custom property successfully. I'm also able to use this value in a driver - but when the value is changed the driver isn't :-( It looks like this is a bug: https://developer.blender.org/T66392
Is there some other way to solve this? I could work around these limitations but changing objects directly in my frame handler, but I'm would prefer to use a driver.
I've using Blender 2.80 RC3.