1
$\begingroup$

one can set the keyframe of an objects location with:

bpy.context.object.keyframe_insert(data_path="location", frame=1)

and it will set the keyframe of the location. Right now I'm trying to add a keyframe to a newly added speaker that I created with python:

NewSpeaker = bpy.ops.object.speaker_add(location=(0,0,0))

following that I change the speakers volume:

bpy.context.object.data.volume = 0.6

this does work propperly and with no issue, so when trying to keyframe the volume like this:

bpy.context.object.keyframe_insert(data_path="volume", frame=1)

I receive the following error message:

TypeError: bpy_struct.keyframe() property "volume" not found

It does work with things such as location or rotation_euler, but nothing in the Object Data Properties.

Things such volume min are not able to have keyframes, but volume and pitch are able to be keyframed.

Is there a way to keyframe the volume with python?

$\endgroup$

1 Answer 1

2
$\begingroup$

Volume is a data property, not an object property.

Don't use:

obj.keyframe_insert("volume")

But use:

obj.data.keyframe_insert("volume")
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .