I want to create an animation where hundreds of objects start to fall, each in different time. I applied Soft Body modifier and set Gravity in Effector Weights to 0 for frame 0. Than for every object I go to random frame and change Gravity to 1. I will probably need to change f-curves to Constant, possibly something else. But this is where I’m stuck now:
I can’t set ID & data path for Active Keying Set and subsequently get error
“Skipping path in Keying Set, as it has no ID (KS = ‘Keying Set’, Path = ‘(null)’[0])”
when adding a key frame. I managed to add an empty path but struggle to change it.
What’s wrong? Better ideas how to make this animation are also welcome
import bpy, random
for obj in bpy.data.scenes['Scene.001'].objects:
if obj.type == 'MESH':
# Go to frame 0
bpy.ops.anim.change_frame(frame=0)
# Only for objects named 'granit...'
isGr = obj.name.find('granit')
if isGr == 0:
# SoftBodyModifier object
mod = obj.modifiers.new(obj.name, 'SOFT_BODY')
# Change modifier settings
mod.settings.use_self_collision = 1
mod.settings.use_goal = 0
mod.settings.effector_weights.gravity = 0.5 # <<< data path, can't set this !!!
# Add path to Active Keing Set
bpy.ops.anim.keying_set_path_add()
path = bpy.types.KeyingSetPath(obj) # <<< doesn't help
#path = bpy.types.KeyingSetPath.path_from_id(obj) # <<< doesn't help either
print(path)
# Add new keypoints at frame 0
bpy.ops.anim.keyframe_insert(type='KeyingSet', confirm_success=True)
# Go to random frame and change gravity
fr = random.randrange(100)
bpy.ops.anim.change_frame(frame = fr)
mod.settings.effector_weights.gravity = 1
bpy.ops.anim.keyframe_insert(type='KeyingSet', confirm_success=True)