2
$\begingroup$

To clarify, say you have ten actions. You want to find all actions that Object1 is affected by. If that object is changed by even a single F-curve in a given action, that counts. Is there a way to do this via code?

If this isn't possible in the current version, I'm also considering a user solution in the form of a naming convention. For example, include the name of the target object in the action name, and that action is added to a list. But I'd prefer to be told that my initial approach isn't feasible before going about it that way.

$\endgroup$
  • $\begingroup$ An object can only ever be assigned 1 action as far as I'm aware, so unless I'm misunderstanding, you would just check which action is assigned to it (if there is one). $\endgroup$ – Ray Mairlot Apr 27 '17 at 21:27
  • $\begingroup$ Do you mean to say an object can only ever have one active action? That's true. But there can be any number of inactive actions that manipulate a given object. What I'm asking is it there's a way to find all actions (active or inactive) that manipulate a specific object. That's I meant by actions an object is "involved" with. $\endgroup$ – Joshua King Apr 28 '17 at 0:17
3
$\begingroup$

An object can have one active action, this is the one that is shown in the action editor. All other actions that affect an object can be found in the objects NLA data.

import bpy

for obj in bpy.context.scene.objects:
    ad = obj.animation_data
    if ad:
        if ad.action:
            print(obj.name,'uses',ad.action.name)
        for t in ad.nla_tracks:
            for s in t.strips:
                print(obj.name,'uses',s.action.name)
| improve this answer | |
$\endgroup$
  • $\begingroup$ To nitpick, an object can have 2 active actions, a transform action and a shape key action: i.imgur.com/6u7CR5N.png :) But yes, action editor shows only the transform action, shape key editor shows the other one. $\endgroup$ – Manu Järvinen Sep 5 '18 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.