Reader small image

You're reading from  Python Scripting in Blender

Product typeBook
Published inJun 2023
PublisherPackt
ISBN-139781803234229
Edition1st Edition
Right arrow
Author (1)
Paolo Acampora
Paolo Acampora
author image
Paolo Acampora

Paolo Acampora is a 3D artist and programmer, with experience in Animation, Visual Effects, and Real Time computer graphics. He provides tools that streamline the production workflow and let artists focus on the creative aspects of their craft. He has worked with several studios for more than a decade. He contributes to the blender development and releases his tools for the community.
Read more about Paolo Acampora

Right arrow

Accessing animation data in Python

Let’s switch to the Scripting Workspace area to familiarize ourselves with the animation system API.

Adding keyframes in Python

The Python class of every animatable object provides a method that we can use to insert keyframes, named keyframe_insert. It is very similar to the Insert Keyframe menu and requires a data_path string for specifying which property to animate. Optional parameters such as index and frame allow us to specify one of the channels of an aggregate property or a frame different from the current one:

keyframe_insert(data_path,
                index=- 1,
                frame=bpy.context.scene.frame_current,
[…]
Returns
        Success of keyframe insertion.

The following lines set a keyframe for the active object...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Python Scripting in Blender
Published in: Jun 2023Publisher: PacktISBN-13: 9781803234229

Author (1)

author image
Paolo Acampora

Paolo Acampora is a 3D artist and programmer, with experience in Animation, Visual Effects, and Real Time computer graphics. He provides tools that streamline the production workflow and let artists focus on the creative aspects of their craft. He has worked with several studios for more than a decade. He contributes to the blender development and releases his tools for the community.
Read more about Paolo Acampora