Way to find all animation nodes/curves/keys on a FBTake?

Hey guys,

I’m trying to find a way to offset all animation inside a take by a given frame range. eg. Shift all animation back 40 frames.

But I’m struggling to find a way to grab all nodes/curves/keys.
I started off this way, but it doesn’t seem to be working for me, any ideas?

for lComponent in FBSystem().Scene.Components:
        for lProp in lComponent.PropertyList: 
            if lProp and lProp.IsAnimatable () and lProp.IsAnimated ():
                anim_node = lProp.GetAnimationNode()
                fcurve = anim_node.FCurve

My way could be a bit slow, so would like to hear a faster way. But you have to find the instances where there is only one property (Focal Length or something), or if it’s split out into several animation nodes (X,Y,Z or RGB).

And I think if you’re moving back in time, you need to remember to do the first keys first (or the last keys first when moving forwards).

# The new start time desired.
start_time = 0
for lComponent in FBSystem().Scene.Components:
    for lProp in lComponent.PropertyList: 
        if lProp and lProp.IsAnimatable() and lProp.IsAnimated():
            animation_node = lProp.GetAnimationNode()
            # For the node, check to see if it has and FCurve or keys.
            if animation_node:
                # Use "if animation_node.Nodes:" here to detect any nodes with more than one fcurve within.
                # Here I'm just using the simplest example with one.
                current_curve = animation_node.FCurve
                if len(current_curve.Keys) > 0:
                    if current_curve.Keys:
                        # Move all the keys to 0 first.
                        first_key = current_curve.Keys[0].Time.GetFrame()
                        # Change the direction of the movement depending on the key offset.
                        if start_time > first_key:
                            # Backwards
                            for x in range(len(current_curve.Keys) - 1, -1, -1):
                                current_frame = current_curve.Keys[x].Time.GetFrame()
                                new_frame = FBTime(0, 0, 0, (current_frame - first_key) + start_time)
                                current_curve.Keys[x].Time = new_frame

This may not be what your looking/something you have already tried, but i have used it for awhile now and it works really well for my needs.

Via Niel3D:
http://neill3d.com/wp-content/uploads/2012/05/CharTimeToZero.zip

Thanks. I was missing the “if animation_node.Nodes” part and kept returning none :s

Thanks that’s cool. Although I want a script that will work with all elements and not just chars. I might steal some of it though so thanks!