1
$\begingroup$

I am trying to randomize some values of selected objects in blender How can I keyframe_instert of the active particle properties? I can do it with clicking "I" of the desired area and it works (creates a keyframe)

I tried: (n

obj = bpy.context.active_object
obj.keyframe_insert(data_path='bpy.data.particles["ParticleSettings"].lifetime')
obj.keyframe_insert(data_path="lifetime")

gave type errors both

TypeError: bpy_struct.keyframe_insert() property "lifetime" not found

n

$\endgroup$
1
$\begingroup$

Set on the object that has the property

Python console code. A default particle system has been added to a Plane that has context.

The lifetime is set to 10 and keyframed on frame 1.

>>> C.object
bpy.data.objects['Plane']

>>> ps = C.object.particle_systems['ParticleSettings'].settings
>>> ps
bpy.data.particles['ParticleSettings']

>>> ps.lifetime
10.0

>>> ps.keyframe_insert("lifetime", frame=1)
True

Notice the objects particle systems settings points to its data item in bpy.data.particles which is the ID object that the action (typically bpy.data.actions['ParticleSettingsAction']) will belong to.

$\endgroup$
1
  • $\begingroup$ thank you so much. I don't know why there is an additional setting I need to add to the end. It does not require it for modifiers. $\endgroup$
    – Raqun Bob
    Jul 1 '20 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.