changing Renderpath problem
-
On 15/03/2013 at 01:15, xxxxxxxx wrote:
Hey NiklasR,
Here is what i belive to be a SSCCE:
import c4d from c4d import gui, plugins, documents import os if __name__=='__main__': doc = c4d.documents.GetActiveDocument() renderData = doc.GetActiveRenderData() xResolution = int(round(renderData[c4d.RDATA_XRES])) yResolution = int(round(renderData[c4d.RDATA_YRES])) pathChange = False if renderData[c4d.RDATA_PATH] != "": storedPath = renderData[c4d.RDATA_PATH] renderData[c4d.RDATA_PATH] =r'{0}_{1}'.format(renderData[c4d.RDATA_PATH], "extension") c4d.EventAdd() pathChange = True renderBmp = c4d.bitmaps.BaseBitmap() renderBmp.Init(x=xResolution, y=yResolution, depth=32, ) result = documents.RenderDocument(doc, renderData.GetData(), renderBmp, c4d.RENDERFLAGS_EXTERNAL) if pathChange == True: renderData[c4d.RDATA_PATH] = storedPath if result==c4d.RENDERRESULT_OK: c4d.bitmaps.ShowBitmap(renderBmp) # show image in pictureViewer
Just create a new scene, save the renderoutput in some folder. If you run this script, the rendered file will actually be output to the folder. If you move the .GetData() to doc.GetActiveRenderData().GetData() and remove it from renderData.GetData(), theres no more file output.
Aurel
-
On 15/03/2013 at 06:21, xxxxxxxx wrote:
Hi Amadeo,
yes that is perfect, thanks.
I'm also very confused, I can reproduce the behavior you describe. I don't see what is wrong
in your code, mine works (see below). Anyway, you could still just save the image by hand. The
script below is doing this as well so you will end up with two images when the Save parameter
is checked in the render-data.import os import c4d def main() : rdata = doc.GetActiveRenderData().GetData() ** # rdata[c4d.RDATA_SAVEIMAGE] = False** xres = int(round(rdata[c4d.RDATA_XRES])) yres = int(round(rdata[c4d.RDATA_YRES])) path = rdata[c4d.RDATA_PATH] if not path: c4d.gui.MessageDialog("no save-path specified") return dirname = os.path.dirname(path) if not os.path.exists(dirname) : os.makedirs(dirname) elif not os.path.isdir(dirname) : c4d.gui.MessageDialog("destination directory can not be created.") return path = '%s_extension' % path ** # rdata[c4d.RDATA_PATH] = path** fileformat = rdata[c4d.RDATA_FORMAT] bmp = c4d.bitmaps.BaseBitmap() if bmp.Init(xres, yres, 32) != c4d.IMAGERESULT_OK: c4d.gui.MessageDialog("could not allocated bitmap for render.") return result = c4d.documents.RenderDocument(doc, rdata, bmp, c4d.RENDERFLAGS_EXTERNAL) if result != c4d.RENDERRESULT_OK: c4d.gui.MessageDialog("rendering was not successful, see console.") print "rendering failed with error-code", result return result = bmp.Save(path, fileformat) if result != c4d.IMAGERESULT_OK: c4d.gui.MessageDialog("rendered bitmap could not be saved, see console.") print "saving bitmap failed with error-code", result main()
It seems to be the setting of the RDATA_PATH, because when you uncomment the red line,
the RenderDocument() function does not save automatically anymore.Best,
-Niklas