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).
My test environment: Cinema 4D version: CINEMA 4D R19.068 Renderer: Octane renderer 3.07 R2
This is my code:
# -*- coding: UTF-8 -*- import c4d from time import sleep # Save path save_path = "D:\\temp" # It's my dir for test. Change it if you dont want to save your bmp at here. class RenderThread(c4d.threading.C4DThread): global save_path # Override def __init__(self, doc, rd, bmp): self.break_flag = False self.doc = doc self.rd = rd self.bmp = bmp self.res = None # Override def Main(self): self.res = c4d.documents.RenderDocument( self.doc, self.rd, self.bmp, c4d.RENDERFLAGS_EXTERNAL ) # Just a test for distinguish the result file is saved by which thread. # If i get this file, it indicates that the render thread has run completed. if self.res == c4d.RENDERRESULT_OK: self.bmp.Save( "{}\\RenderThread_SaveResult.jpg".format(save_path), c4d.FILTER_JPG ) # Override def TestDBreak(self): return self.break_flag # This method is main thread. def main(): global save_path doc = c4d.documents.GetActiveDocument() rd = doc.GetActiveRenderData().GetData() bmp = c4d.bitmaps.BaseBitmap() bmp.Init(rd[c4d.RDATA_XRES], rd[c4d.RDATA_YRES]) th = RenderThread(doc, rd ,bmp) th.Start() count = 0 # When "count" equals 10, end render thread. while True: print "Current count ->", count # Show bmp to picture viewer c4d.CallCommand(430000740, 430000740) # Remove All Images --> Clear history, just show current bmp c4d.CallCommand(430000774, 430000774) # Auto Zoom Mode --> Zoom picture to fit the picture viewer c4d.bitmaps.ShowBitmap(bmp) # Listen for the running state of the render thread. is_run = th.IsRunning() print "Is render thread running ->", is_run if not is_run: print "End Render Thread" # If i get this file, it indicates that the render thread has run completed. if th.res == c4d.RENDERRESULT_OK: th.bmp.Save( "{}\\MainThread_SaveResult.jpg".format(save_path), c4d.FILTER_JPG ) break # Test of break render thread if count == 10: print "Break Render Thread" th.break_flag = True break_res = th.TestBreak() print "TestBreak() result ->", break_res if break_res: th.End(False) # It doesn't work... and the bottom of result image have a state bar... print "Execute End()..." print "Is render thread still running ->", th.IsRunning() # If i get this file, it indicates that the render thread has break. th.bmp.Save( "{}\\Break_SaveResult.jpg".format(save_path), c4d.FILTER_JPG ) break count += 1 sleep(1) if __name__ == "__main__": c4d.CallCommand(13957) # Clear Console main()
There has two questions:
Finally, I will got two images, because render thread doesn't break:
Hi,
You end the thread, but you use false as an argument meaning that you don't wait, that's why it's still running if you ask immediately after.
The question about the status at the bottom, i would say that octane does override that part of the frame until the render is finished. But that's just a guess, you should ask the devs from Otoy about that on their forum.
Cheers, Manuel
Hello @Артём,
we will set this topic to 'Solved' when there are no further questions or replies until Monday, November the 22th.
Thank you for your understanding, Ferdinand