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

    Render sequence from viewport

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 306 Views
    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 Offline
      Helper
      last edited by

      On 30/10/2016 at 14:53, xxxxxxxx wrote:

      Hi guys! I have I think a simple task. 
      Just what I want is to render sequence of frames form viewport. Script should call render the current frame and then go to next frame and then call the render current frame again and ect. I started with something but my problem is how to go back from thread to main function and call render again?

      import c4d
      import os,time, thread

      onRender = False

      def isRendering(time,os) :
          
          while c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING ) :
              time.sleep(1)
              onRender = True
              print (onRender)
          
          onRender = False
          print (onRender)
          thread.exit()
      # here I need to call render current frame

      def main() :
          
          c4d.CallCommand(12099) # Render Current Frame
          thread.start_new(isRendering,(time,os)) 
          c4d.CallCommand(12414) # Go to Next Frame
          print ("next frame")
          
      if __name__=='__main__':
          main()

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

        On 31/10/2016 at 09:16, xxxxxxxx wrote:

        Hi Alex,

        welcome to the Plugin Café forums 🙂

        In general we do not recommend to use threads in scripts (i.e. started from the Script Manager).
        Rather I'd implement a CommandData plugin (just a few more lines compared to your script, you'd use this to start the rendering) and a MessageData plugin (to receive a "done" message, see below).

        Instead of plain Python threads we recommend C4D's own C4DThread.

        Instead of using CallCommand() I'd recommend to use directly RenderDocument() in a thread (another example on how to use RenderDocument() is in tokensystem_render.py).
        When you take a look at the code snippets in documentation or in the example, you will see, that setting up customized RenderData is quite easy. So maybe you need not render every single frame separately, but could instead simply set up a frame range in RenderData and do one RenderDocument for all wanted frames.
        And then, when your thread is done with rendering you can use SpecialEventAdd() to send a CoreMessage to the above mentioned MessageData plugin, where you receive it in CoreMessage() and are back in the main thread.

        Some more information on CoreMessages can be found in the latest C++ docs: Custom Messages
        Also in C++ docs: RenderData Manual and BaseDocument - Render

        Just an idea and of course only one way of doing it.

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

          On 01/11/2016 at 11:41, xxxxxxxx wrote:

          Thank you, Andreas, I don't know if I can use your advise because I have no enough knowledge in this field, but I try.

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