while playing around with
c4d.documents.RenderDocument, I found some strange behavior in certain flags, so I wonder whether the documentation is correct. Here's what I'm going with:
import c4d from c4d import gui def main(): currentRenderData = doc.GetActiveRenderData() rdata = currentRenderData.GetData() imageWidth = int(currentRenderData[c4d.RDATA_XRES]) imageHeight = int(currentRenderData[c4d.RDATA_YRES]) bmp = c4d.bitmaps.MultipassBitmap(imageWidth, imageHeight, c4d.COLORMODE_RGB) bmp.AddChannel(True, True) result = c4d.documents.RenderDocument (doc, rdata, bmp, c4d.RENDERFLAGS_EXTERNAL | c4d.RENDERFLAGS_OPEN_PICTUREVIEWER) if result == c4d.RENDERRESULT_OK : print ("Render ok") # c4d.bitmaps.ShowBitmap(bmp) elif result == c4d.RENDERRESULT_OUTOFMEMORY : print ("Error in rendering - Out of memory") elif result == c4d.RENDERRESULT_ASSETMISSING : print ("Error in rendering - Asset missing") elif result == c4d.RENDERRESULT_SAVINGFAILED : print ("Error in rendering - Failed to save") elif result == c4d.RENDERRESULT_USERBREAK : print ("Error in rendering - User break") elif result == c4d.RENDERRESULT_GICACHEMISSING : print ("Error in rendering - GI cache is missing") elif result == c4d.RENDERRESULT_NOMACHINE : print ("Error in rendering - Machine not found") # Only in Team Render elif result == c4d.RENDERRESULT_PROJECTNOTFOUND : print ("Error in rendering - Project was not found") # Only in command line render elif result == c4d.RENDERRESULT_ERRORLOADINGPROJECT : print ("Error in rendering - Error while loading project") # Only in command line render elif result == c4d.RENDERRESULT_NOOUTPUTSPECIFIED : print ("Error in rendering - Output was not specified") # Only in command line render if __name__=='__main__': main()
RENDERFLAGS_OPEN_PICTUREVIEWERdoes nothing. Explanation is "Open the Picture Viewer." but that doesn't happen. Nor does the finished image appear in the PV once I open it manually. (Note that I commented out
ShowBitmapin the code above on purpose.)
RENDERFLAGS_CREATE_PICTUREVIEWERdoes enter the image in an existing Picture Viewer with the correct name and time. If no PV is open, none is opened at this point even if the image will be shown if I open one manually. But the explanation is "Render in a new Picture Viewer." which I would interpret as "opening a new one"... maybe the explanation should be different.
RENDERFLAGS_SHOWERRORSfreezes my process - I have to kill C4D with the task manager. I'm not sure how to use that at all... does it require a parallel thread? I can't tell where the promised dialog would open...
RENDERFLAGS_EXTERNALis explained as "External render." (no comment...). In R19, the explanation was "Use render settings for LOD etc. (Otherwise the current document settings are used.)" which at least gives me some idea what this flag actually means. Was the text changed for a purpose? If yes, what does the flag do now?
As for the return values, I was unable to provoke a
RENDERRESULT_ASSETMISSING. I created a material with an image texture and then renamed the file on disk. I get
RENDERRESULT_OK anyway, with the material just missing in the final image. I tried the
SHOWERRORS flag but the C4D process froze.
An empty file path in the render settings while having Save activated still doesn't cause a
RENDERRESULT_SAVINGFAILED (naturally nothing is saved). Maybe it's only my expectation that it would? (Sorry, I was lazy and didn't test other file saving exceptions like Windows access rights...)
(btw in the current online documentation the result constants are mashed into one line, missing a proper Return, and maybe
RENDERRESULT_OK should be listed too)
And finally, while the documentation contains a fine example for callbacks, I don't quite see how to interrupt the rendering to return
RENDERRESULT_USERBREAK. I've been reading through quite a few historic posts on this forum regarding threading of
RenderDocument, but by now I have the feeling that it's just not possible.