Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. martijnlambada
    M

    martijnlambada

    @martijnlambada

    0
    Reputation
    2
    Posts
    13
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    martijnlambada Follow

    Best posts made by martijnlambada

    This user hasn't posted anything yet.

    Latest posts made by martijnlambada

    RE: Keyframing a property using python.

    Hi Manual,

    Thanks for your help! Next time I will use the 'ask question' when posting a question.
    You code does exactly what I need, much appreciated!

    Cheers,
    Martijn

    posted in Cinema 4D SDK •
    Keyframing a property using python.

    Hi all,

    I’m trying to make a little script that takes all selected cameras and puts them in a (newly created) stage object (one camera per frame).

    Super useful if you want to render out stills on a render farm that doesn’t support takes.

    I’ve got almost everything working:

    • Getting the selected cameras and putting them in an array.
    • Creating a stage object
    • Looping through the array and putting the cameras into the camera slot of the stage object.
    • Moving 1 frame forward

    The two things I’m struggling with:

    1. How to key frame the camera slot properly so it actually creates the animation (different camera per frame). I’m using the mydoc.RecordKey() property but how do I find out which id (?) the camera property has?
    2. Ideally I want to catch errors when someone selects something other than a camera. Is there an easy way to catch that error? Should I loop through the array and check the individual elements?

    Who can point me into the right direction?

    Your help is much appreciated.

    Best regards,
    Martijn

    script:

    import c4d, math
    from c4d import gui
    
    # This is a little script that puts the selected cameras into a stage object with keyframes
    
    
    # Main function
    def main():
        # Clear Console for easy debugging
        c4d.CallCommand(13957, 13957)
    
        # Get selected cameras
        obj = doc.GetActiveObjects(1)
    
        # Check if selected objects are cameras, if not pop-up error
        #code should come here
    
    
        # Go to Start of timeline
        c4d.CallCommand(12501)
    
        #create stage object
        stage = c4d.BaseObject(c4d.Ostage)
        doc.InsertObject(stage)
    
        # Get active document
        mydoc = c4d.documents.GetActiveDocument()
    
        # Loop through the array of cameras & put selected cameras in stage object
        for x in obj:
            mytime = mydoc.GetTime()
            myfps = mydoc.GetFps() # define prject fps
            myframe = mytime.GetFrame(myfps) #get current frame
            print(myframe) # print frame number
    
            stage[c4d.STAGEOBJECT_CLINK] = x # put camera camera slot of stage object
    
            #set keyframe How??
            #mydoc.RecordKey(stage,[c4d.ID_BASEOBJECT_REL_ROTATION,c4d.VECTOR_X]) #Add the keyframe to Rotation X successfully
            mydoc.RecordKey(stage, 1)
    
    
    
            # Go to next key frame
            c4d.CallCommand(12414)
    
        c4d.EventAdd() #update
    
    
    
    # Execute main()
    if __name__=='__main__':
        main()
    
    posted in Cinema 4D SDK •