Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
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()
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.
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.