Hello!
I'm rendering an image in my plugin with documents.RenderDocument() and using StatusSetSpin().
With the code below, I'm using RenderDocument()'s prog
parameter function to update the Status progress bar. Currently this code shows the spinner, but the render progress isn't given until after the rendering has completed which is unexpected. With the progress_type
RENDERPROGRESSTYPE_DURINGRENDERING
, I'd expect the function to execute during rendering rather than afterwards. Perhaps it is, but the UI gets frozen during rendering. With longer renders (like with the Zombie - Toon Rig scene from the Content Browser), the StatusBar doesn't get cleared with the code I have below. Here are my questions:
- If this is working as intended, is there a way to animate the progress bar while the document is rendering?
- How do I guarantee that c4d.StatusClear() is going to get called after the progress updates?
import c4d
from c4d import documents
def updateProgressBar(p, progress_type):
if progress_type == c4d.RENDERPROGRESSTYPE_BEFORERENDERING:
print("Before Rendering")
c4d.StatusSetText('Initializing render...')
c4d.StatusSetSpin()
elif progress_type == c4d.RENDERPROGRESSTYPE_DURINGRENDERING:
print(p)
c4d.StatusSetText('Rendering...')
c4d.StatusSetSpin()
elif progress_type == c4d.RENDERPROGRESSTYPE_AFTERRENDERING:
print("After Rendering")
c4d.StatusClear()
c4d.EventAdd()
def main(doc):
rd = doc.GetActiveRenderData().GetData()
bmp = c4d.bitmaps.BaseBitmap()
bmp.Init(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), 24)
documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL, prog=updateProgressBar)
c4d.StatusClear()
c4d.StatusSetText('Render complete.')
c4d.EventAdd()
if __name__=='__main__':
main(doc)
Thank you!