Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Play/Pause control via Python

    PYTHON Development
    0
    3
    651
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 03/09/2017 at 04:53, xxxxxxxx wrote:

      Is it possible to control timeline's play/pause via Python or Xpresso in someway?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 03/09/2017 at 05:22, xxxxxxxx wrote:

        Using the Console log

            c4d.CallCommand(12412) # Play Forwards
        

        But the problem with that is you don't have a lot of control about it. So I propose you to use this method instead which allow you to customize how you want to play the animation.

        import c4d
          
          
        def main() :
            fps = doc.GetFps()
            frame = 0 #Starting frame
            maxFrame = doc.GetLoopMaxTime().GetFrame(fps) #end frame
          
          
            #Loop until our frame number is egual to our max frame
            while frame < maxFrame:
        	
        	#We change the time
                doc.SetTime(c4d.BaseTime(frame, fps))
        		
        	#We redraw everything
                c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW)
        		
        	#Send message to tell c4d the time changed
                c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
                    
        	#Do something here...
        	c4d.CallCommand(12410) # Record Active Objects
        		
        	#we define our next frame
                frame += 1
            
            #Update the whole scene
            c4d.EventAdd()
          
          
        if __name__=='__main__':
            main()
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 04/09/2017 at 02:46, xxxxxxxx wrote:

          Hi,

          there's also RunAnimation(), which works quite nicely.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post