On 09/04/2013 at 10:53, xxxxxxxx wrote:
Thanks Sebastien,
I've got it working now. And it does render the scene while I'm also working on it.
But I'm having trouble with ending the thread properly.
I'm not 100 % ceratin. But it seems like the thread never ever stops?:
import c4d
from c4d import documents
from c4d import utils, bitmaps, storage,plugins
#get an ID from the plugincafe
PLUGIN_ID = 1000001
class RenderThread(c4d.threading.C4DThread) :
bmp = c4d.bitmaps.BaseBitmap()
def Main(self) :
doc = c4d.documents.GetActiveDocument()
rdata = doc.GetActiveRenderData()
rdata = rdata.GetClone(c4d.COPYFLAGS_NO_HIERARCHY)
w = rdata[c4d.RDATA_XRES]
h = rdata[c4d.RDATA_YRES]
rdata[c4d.RDATA_SAVEIMAGE] = True
bmp = c4d.bitmaps.BaseBitmap()
bmp.Init(int(w), int(h), 32)
bmp = c4d.documents.RenderDocument(doc, rdata.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL)
class SceneRender(c4d.plugins.CommandData) :
doc = c4d.documents.GetActiveDocument()
thread = RenderThread()
image = thread.bmp
def Execute(self, doc) :
self.thread.Start()
self.thread.End(False)
if self.thread and not self.thread.IsRunning() : print "Render Finished" #<------ This never happens!!! Thread never stops?
return True
if __name__ == "__main__":
help = "The text shown at the bottom of C4D when the plugin is selected in the menu"
plugins.RegisterCommandPlugin(PLUGIN_ID, "SceneRender", 0, None, help, SceneRender())
-ScottA