how to assign an action to several objects

I want to assign an action to several objects, but don’t know how to achieve it. I tried to read blender python api, but found nothing useful. Can someone help?

1 Like

hi there…
you can do it this way!

bpy.context.active_object.animation_data.action = bpy.data.actions["action_name"]

for selected objects it can be done this way:

for ob in bpy.context.selected_objects:
    ob.animation_data.action = bpy.data.actions["action_name"]
1 Like

Hi!

I tried running this script, but there is a small issue: the objects I have selected already contain one action beforehand. Is there any way of modifying this script so that it will respect the actions the selected objects already have? In other words I need to only append this new action while also keeping the old ones intact.

You can’t reference multiple actions per object, only one action can be associated.

1 Like

Now I’m confused. Isn’t the NLA editor meant for blending multiple actions of an object together? That makes me think that an object could have several different actions, but maybe I have misunderstood something?

Object.animation_data.action can only reference a single action at any time. NLA does not store its data on object level.