How to Save a rendered image & Add Canvases
info_eadb99589d
Posts: 5
Hello, I have just started with Daz scripting. I'm trying to load a file, add a canvas and save the rendered image as a png. I have been able to load a file, start the render and activate the canvases but I can't find out how to add an Emission or Glossy canvases. I have been able to render an image but I can't activate the render to file. Here is the current code:
var TempFile = "Z:/01Test.duf"; var oContentMgr = App.getContentMgr();oContentMgr.openFile(TempFile, false);print("scene Loaded");var TempRenderer = App.getRenderMgr();var TempRenderOptions = TempRenderer.getRenderOptions();TempRenderOptions.renderImgFilename = "Z:/01TestSave.png";TempRenderOptions.renderImgTarget = 2; // Direct to file (doesn't work)TempRenderOptions.applyChanges();//TempRenderOptions.renderImgTold = 2; // Tried this but also doesn't seem to workprint(TempRenderOptions.renderImgFilename);if (!TempRenderer.doRender(TempRenderOptions)) { MessageBox.critical("Render Canceled. ","Render","&OK",""); }else { //TempRenderer.saveLastRender(); // Manual save }var TempData = App.getRenderMgr().getRenderElementObjects();if(TempData[1].name == "NVIDIA Iray Render Options") { if(TempData[1].getProperty(3).name == "Max Time") { var TempProperty = TempData[1].getProperty(3); // Max Time TempProperty.setValue(200); print("Max Time:"+TempProperty.getValue()); TempData[1].renderToCanvases = true; // I have manually added a canvas for testing how to add one and this gives me it's name but I can't add one by script print("Canvas:"+TempData[1].getCanvasDefinition(0).name); //TempData[1].clearCanvasDefitions(); } else { MessageBox.critical("Property 'Max Time' not found.","Render","&OK",""); } }else { MessageBox.critical("Could not find 'NVIDIA Iray Render Options'.","Render","&OK",""); }print("Script Ended.");
This thread has helped a lot but I'm missing information on how to add a canvas: https://www.daz3d.com/forums/discussion/196346/how-to-access-advanced-section-in-iray-render-settings
Thanks.
Comments
findCanvasDefition with second parameter set to true adds new canvas ! ;-)
Hi, I tried the findCanvasDefition code.
I want add depth canvas, it raised error.
Is it my fault?
BTW, I am new to DAZ script, so I want to how to find these api information.
Thanks!
Is it not spelled Definition?
Yes, Thank you. It is ok. I just copy, not check. Now I face another problem, how to change the canvas type.
The class is DzIrayCanvasDefinition. Where can I find its function members? I can't find it in api reference. So I want to know how you use these APIs.
Thank you for your reply.
Hi everyone, I find how to know one class's members and how to change canvas type.
I’m not familiar with JavaScript, otherwise I can know how to do it earlier
This works for me to dump the render straight to a file:
Note that undocumented features which you figure out by diging are not at all gur=aranteed to be safe - they may eb chnaged as any time, without notice - so don't rely on them in work you are doing for others or which you need to work reliably over an extended period.