On 08/04/2013 at 14:33, xxxxxxxx wrote:
I also tried it in a simple Command plugin.
But I'm still getting the same results. Everything is frozen until the rendering is finished.
import c4d
from c4d import gui
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) :
def __init__(self, doc, bmp) :
super(RenderThread, self).__init__()
self.doc = doc
self.bmp = bmp
def render(self) :
print "rendering"
w, h = self.bmp.GetSize()
rdata = self.doc.GetActiveRenderData()
rdata = rdata.GetClone(c4d.COPYFLAGS_NO_HIERARCHY)
rdata[c4d.RDATA_XRES] = w
rdata[c4d.RDATA_YRES] = h
rdata[c4d.RDATA_SAVEIMAGE] = True
self.bmp = c4d.documents.RenderDocument(self.doc, rdata.GetData(), self.bmp, c4d.RENDERFLAGS_EXTERNAL)
class SceneRender(c4d.plugins.CommandData) :
def Execute(self, doc) :
bmp = c4d.bitmaps.BaseBitmap()
bmp.Init(600, 300, 32)
w, h = bmp.GetSize()
thread = RenderThread(doc, bmp)
thread.Start()
thread.render()
#thread.Wait(False)
c4d.bitmaps.ShowBitmap(bmp)
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, "Scene Render", 0, None, help, SceneRender())
-ScottA