Jump to content

Sign in to follow this  
MZEEE

Jump 10 frames in the timeline

Recommended Posts

Is there a way to jump 10 frames in the timeline the way you can in After Effects?

Here is an old post but the code doesn't work in R19-R20.

 

Share this post


Link to post
Share on other sites

Works for me in R20/21. Maybe you have the indents not aligned ?

 

import c4d



def main():

    for x in range(10): # Loops 10 times

        c4d.CallCommand(12414) # Goto Next Frame

if __name__=='__main__':

    main()

indent is 4 spaces - use tab

Share this post


Link to post
Share on other sites
  • Topic Author
  • Perfect, Thx jed.

    Didn't know indents are important.

    Share this post


    Link to post
    Share on other sites

    It's how Python marks out blocks of code eg a conditional statement or a for loop controls the lines below that are indented.

    Share this post


    Link to post
    Share on other sites

    @jed
    Just piggy backing on the question, do you know a long-cut method of moving the playhead for the next frame in Python (i.e. utilizing the API) ? Currently, what you have is using the CallCommand which is good but I try to avoid. 

     

    Share this post


    Link to post
    Share on other sites

    Sorry, I don't know the answer to that.

    Share this post


    Link to post
    Share on other sites

    @jed

    No worries. Will probably ask the plugincafe on this one. 

    Anyhow, if you want some API stuff for modifying animation/keyframe. You can check this one: 
    https://github.com/kattkieru/tradigitools/blob/master/README.md

    It jumps frames per API but it only works for frames but not necessarily by playhead.

    Share this post


    Link to post
    Share on other sites
    9 hours ago, bentraje said:

    No worries. Will probably ask the plugincafe on this one. 

     

    Before you die of curiosity, here's a way to work with the BaseTime class to jump forward 10 frames:

    import c4d
    from c4d import gui
    
    def main():
        # main class here: BaseTime
        bt = doc.GetTime()
        print bt.GetNumerator(), bt.GetDenominator(), bt.Get(), doc.GetFps(), bt.GetFrame(doc.GetFps())
        # WRONG: btAdd = c4d.BaseTime(10.0 / doc.GetFps()) will yield a nasty fraction
        # doc.SetTime(bt + btAdd)
        
        # instead, work with the rational numbers in terms of numerator and denominator
        bt2Num = 10.0 # jump forward so many frames
        bt2Den = doc.GetFps()
        print bt2Num, bt2Den
        bt2 = c4d.BaseTime(bt2Num, bt2Den)
        print bt2
        # the addition will take care of the different denominators
        doc.SetTime(bt + bt2)
        doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_0)
    
    if __name__=='__main__':
        main()
    

    Gosh, the background really clashes with the code colors.

     

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...