Need Help - Apply actions to respective empties.

Hi, Need help here.

I have a blend file named A.blend with 10 empties having naming as 1,2,3…etc and these 10 empties have indiviual random animation.

Now I created a new blend named B.blend with 10 empties with same naming as above but all are at static location 0,0,0.

I append the actions from file name A.blend into the current B.blend and applied the action to each empty object in file, it was a success.

Now my question, Is there a method or a script that can assign the actions to empty objects it in one go. No more select individual empty and apply action.

This will be helpful. Please Guide.

If the name of ActionClip is the “object name”+“Action” (default name), this script must be work correctly.
Select the objects and run the script.


import bpy

SELOBJS= bpy.context.selected_objects


for OBJECT in SELOBJS:
    OBJECT.animation_data.action = bpy.data.actions[str(OBJECT.name)+"Action"]

Greetings!

Hi thanks for the code.
But it seems it does not work.

I appended the action from animation file. I can even see the action name in action editor.
I select all the empties in the current with no motion. And run the script.

I get a which says “error at line 7”
Attribute error: ‘None Type’ object has no attribute ‘action’

I am missing something.

Please guide

I was using blender 2.58a.

Thanking you

Fixed it,:slight_smile:

Thanks a lot

I have to append action then have to set a key to all object and then run the script.
Without setting a key the script gives a error

“error at line 7”
Attribute error: ‘None Type’ object has no attribute ‘action’

But if a key and then run the script it works.

Anyway thanks a lot for the script :slight_smile:

Need to ask you, By some way can that can be solved.

Great!, enjoy it! :eyebrowlift:

Greetings.