Navigation

 ·   Wiki Home
 ·   Wiki Help
 ·   Categories
 ·   Title List
 ·   Uncategorized Pages
 ·   Random Page
 ·   Recent Changes
 ·   RSS
 ·   Atom
 ·   What Links Here

Search:

 

Create or Find Page:

 

View Python: Keyframe Selections

Attributes in Cinema 4D can be added to “Keyframe Selection” via the Animation submenu of the Attribute Context Menu. In Autokey mode, only parameters in the Keyframe Selection will be recorded. Attributes in the Keyframe Selection are colored dark orange.

To parse the keyframe selection, you need to use the BaseList2D.FindKeyframeSelection() method. This requires you to pass it a DescID. Prior to 15.037 you’d have to build your own list of possible IDs to loop through and check, but with 15.037 and later you can use the Description class to get all possible ids for an object. There is one hitch - the Description iterator doesn’t parse subchannels (like Vector XYZ), so you need to do that part manually.

Here’s an example convenience function:

def GetKeyframeSelection(op):
    if not op or not op.KeyframeSelectionContent():
        return None
    
    keySelection = []
    desc = op.GetDescription(c4d.DESCFLAGS_DESC_0)
    for bc, paramid, groupid in desc:
        
        #print paramid
        
        #Handle Vectors - seems desc iterator only does top level
        if paramid[0].dtype == c4d.DTYPE_VECTOR:
            for i in xrange(c4d.VECTOR_X,c4d.VECTOR_Z+1):
                did = c4d.DescID(paramid[0],c4d.DescLevel(i,c4d.DTYPE_REAL,0))
                if op.FindKeyframeSelection(did):
                    keySelection.append(did)
        
        #Handle top level DescIDs
        elif op.FindKeyframeSelection(paramid):
            keySelection.append(paramid)
            
    return keySelection

def main():
    keySelection = GetKeyframeSelection(op)
    if keySelection:
        print "*"*4,"Keyframe Select IDs","*"*4
        print keySelection