Community
Arnold for Katana Forum
Rendering with Arnold in Katana using the KtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ktoa ArnoldMarerialXBake issue

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1325 Views, 9 Replies

ktoa ArnoldMarerialXBake issue

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

Tags (3)
Labels (3)
9 REPLIES 9
Message 2 of 10
Stephen.Blair
in reply to: Anonymous

We already answered this on your Slack channel...was that answer no good?



// Stephen Blair
// Arnold Renderer Support
Message 3 of 10
Anonymous
in reply to: Stephen.Blair

oh, sorry. I haven't been noticed about that (slack channel).

Message 4 of 10
Stephen.Blair
in reply to: Anonymous

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)




// Stephen Blair
// Arnold Renderer Support
Message 5 of 10
Stephen.Blair
in reply to: Anonymous

Hi @Jonathan

bake is supposed to be synchronous (see the answer below), so if it isn't, we have a new bug...



// Stephen Blair
// Arnold Renderer Support
Message 6 of 10
Anonymous
in reply to: Stephen.Blair

I've tested your snippet and seems like it does exactly what we were looking for. Thank you.

Message 7 of 10
Anonymous
in reply to: Anonymous

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



Message 8 of 10
Anonymous
in reply to: Stephen.Blair

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


Message 9 of 10
michael.farnsworth
in reply to: Anonymous

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.

Message 10 of 10
Anonymous
in reply to: michael.farnsworth

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.

Post to forums  

Autodesk Design & Make Report