How to add PLA keyframes



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/03/2011 at 14:15, xxxxxxxx wrote:

    I'm trying to import obj files one for each frame, and add PLA keyframes in C4D, but am not finding anyway to do it using python.  Is this even the right way to approach this problem?

    I'm using C4D R12, trying to import cloth animation from massive.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/03/2011 at 17:38, xxxxxxxx wrote:

    So after three days of pain and suffering through bad docs and C++ decoding, I have a python solution.

    import c4d
    from c4d import utils
    import os

    DEBUG = True
    BUILDFLAGS_0 = 0

    def main() :
        '''Updates an objects keyframes for all frames'''

    #get the object to animate
        obj = doc.SearchObject('Cube')

    #get the pla track Description id
        id = c4d.DescID(c4d.DescLevel(c4d.CTpla, c4d.CTpla, 0))

    # check if track already exist

    plaTrack = obj.FindTrack(id)

    if plaTrack == None:

    #Create the pla track
        plaTrack = c4d.CTrack(obj, id)
        obj.InsertTrackSorted(plaTrack)

    else:

    plaTrack.FlushKeys()

    ctime = doc.GetTime() #save current time

    fps = doc.GetFps()
        start = doc.GetMinTime().GetFrame(fps)  #set min time
        until  = doc.GetMaxTime().GetFrame(fps) #set max time

    #get the plaTrack curve
        myCurve = plaTrack.GetCurve()

    #setup SendModelingCommand base container
        settings = c4d.BaseContainer()
        settings.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE, True)
        settings.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, False);

    # loop thru each frame
        for f in xrange(start, until) :

    #set the next frame
            time = c4d.BaseTime(f, fps)
            doc.SetTime(time)
            doc.ExecutePasses(None, True, True, True, BUILDFLAGS_0);

    #update timeline
            c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)

    #create new object
            newobjList = utils.SendModelingCommand(
                                command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                list= [obj],
                                mode=c4d.MODELINGCOMMANDMODE_ALL,     # mode
                                bc=settings,
                                doc = doc)

    newObj = newobjList[0]

    if newObj != None:

    #get the points from the new object
                points = newObj.GetAllPoints()

    #add the key frame
                dictKey = myCurve.AddKey(time)
                key = dictKey["key"]

    #modify points for current frame
                points[3].x = points[3].x + 25.0
                newObj.SetAllPoints(points)
                newObj.Message(c4d.MSG_UPDATE)

    #sync key frame with point data
                fillSuccess = plaTrack.FillKey(doc,newObj,key)
                if fillSuccess == False:
                    print('Fill key failed for frame {0}'.format(f))

    else:
                print('CURRENTSTATETOOBJECT failed to create new object')



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/03/2011 at 12:11, xxxxxxxx wrote:

    Thanks for posting your solution! I hope more people would do it :)
    I know it can be frustrating at times, but the end result is worth it.


Log in to reply