[obj.keyframe_insert, bpy.data.particles["ParticleSettings"].lifetime]; how to insert keyframe to an existed particle setting, e.g lifetime 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 &quot;I&quot; 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[&quot;ParticleSettings&quot;].lifetime')
obj.keyframe_insert(data_path=&quot;lifetime&quot;)

gave type errors both
TypeError: bpy_struct.keyframe_insert() property &quot;lifetime&quot; not found
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.
&gt;&gt;&gt; C.object
bpy.data.objects['Plane']

&gt;&gt;&gt; ps = C.object.particle_systems['ParticleSettings'].settings
&gt;&gt;&gt; ps
bpy.data.particles['ParticleSettings']

&gt;&gt;&gt; ps.lifetime
10.0

&gt;&gt;&gt; ps.keyframe_insert(&quot;lifetime&quot;, 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.