Hi,
We are using 'ArnoldMaterialXBake' in a pipeline as a publishing tool to export materialX files from Katana.
(using ktoa-3.2.# / arnold-6.2.#)
https://docs.arnoldrenderer.com/display/A5KTN/ArnoldMaterialXBake
We are using node's 'bake()' method in order to automate the export process.
We are having an issue where it seems impossible (or we just don't know how) to know when the 'bake' process ends, while it seems to process in a different thread then the current one.
Here's a snippet as an example of what we are doing...
node = NodegraphAPI.GetNode('ArnoldMaterialXBake') filepath = '/tmp/tmpT4ev0n/test.mtlx' node.getParameter('saveTo').setValue(filepath, 0) node.bake() print 'BAKE PROCESS START---' i = 0 while not os.path.isfile(filepath): i += 1 time.sleep(0.5) print 'File exists, elapsed seconds: ', i/2
Would result in;
BAKE PROCESS START--- File exists, elapsed seconds: 4.0
Is there anything we could do in order to access when the `bake()` process ends?
ie; Other then fetching if the file exists in a while loop.
Thanks
Solved! Go to Solution.
Solved by Stephen.Blair. Go to Solution.
We already answered this on your Slack channel...was that answer no good?
bake should be running synchronously
from SuperTools/ArnoldMaterialXBake/v1/Node.py
# Run the export! log.info('Exporting MaterialX file to %s' % saveTo) from Katana import RenderManager settings = RenderManager.RenderingSettings() settings.asynch = False RenderManager.StartRender('materialXRender', node=renderNode, settings=settings)
I've tested your snippet and seems like it does exactly what we were looking for. Thank you.
Thanks Stephen, this seems to work fine!
Just to mention, it still seems that the bake() operation is necessary here, I do not know if it's intended or not...
As an example, I made a simple scene with 4 primitive, each assigned with a different material.
settings = RenderManager.RenderingSettings() settings.asynch = False mtlxNode = NodegraphAPI.GetNode('ArnoldMaterialXBake1') saveTo = mtlxNode.getParameter('saveTo') rootLocation = mtlxNode.getParameter('rootLocations.i0') for i in range(4): path = '.../tmp/primitive{}.mtlx'.format(i) saveTo.setValue(path, 0) rootLocation.setValue('/root/world/geo/primitive{}'.format(i), 0) # mtlxNode.bake() RenderManager.StartRender('materialXRender', node=mtlxNode, settings=settings) print 'done ---', os.path.isfile(path), path
Would not output anything and result in;
done --- False .../tmp/primitive0.mtlx done --- False .../tmp/primitive1.mtlx done --- False .../tmp/primitive2.mtlx done --- False .../tmp/primitive3.mtlx
Unless I uncomment the mtlxNode.bake() line. In this case, all 4.mtlx files would render and output as expected.
Does it seem like bug or the normal behavior?
thanks,
Jonathan
Thanks Stephen for the quick answer.
That snippet you provided seems to work fine.
However, it still seems the bake() operation is necessary here, along with the RenderManager.StartRender().
I do not know if it's intended or not, made an example below.
thanks again,
Jonathan
The bake() is actually what's running the render internally, so you shouldn't need your own call to RenderManager.StartRender(). The bake call should run a synchronous render and not return until it is complete, and if it returns before then that's a bug we should fix.
Thanks for having a look.
From the 1st snippet I posted, can you validate you have the same results?
ie;
node.bake() print 'BAKE PROCESS START---' i = 0 while not os.path.isfile(filepath): i += 1 time.sleep(0.5) print 'File exists, elapsed seconds: ', i/2
Would run an asynchronous render and therefore would print many iterations before the render finishes it's process (and mtlx file would not be available before the end process).
Should I create a bug ticket somewhere or it's already registered on your end?
thanks,
Jonathan
Can't find what you're looking for? Ask the community or share your knowledge.