Jump to content

Jump 10 frames in the timeline


THEMZ

Recommended Posts

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

Link to post

@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. 

 

Link to post
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.

 

Link to post
  • 3 months later...
On 10/4/2019 at 7:48 AM, jed said:

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

Brilliant! i'm working on a walk cycle and i need to switch between left and right poses. this is perfect. thanks so much!

Link to post

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

ABOUT US

We are dedicated Cinema 4D Community of friendly and passionate artists, hobbyists and developers. Feel free to join us and share your knowledge, your art and anything that might help Community to grow. We are providing guidance, free plugins and files, feedback, sponsorships and various discounts for our Contributors. :cowboypistol:

SUPPORT

Tickets

Purchases

×
×
  • Create New...

Copyright C4D Cafe © 2020 Powered by Invision Community