Given an assfile which contains a mesh_light and a polymesh,
where the 'mesh' parameter of the mesh_light is correctly linked to
the polymesh...
Using the Python API, how do I query the mesh_light's 'mesh' parameter to get the polymesh node? I've used 'SetPtr' a lot to create these links but
I can't quite get the hang of querying them..
I have this snippet:
AiBegin() AiASSLoad(ass_file, AI_NODE_ALL) iter = AiUniverseGetNodeIterator(AI_NODE_ALL) while not AiNodeIteratorFinished(iter): node = AiNodeIteratorGetNext(iter) if AiNodeIs(node, 'mesh_light'): meshPtr = AiNodeGetPtr(node, "mesh")
How do I use the integer pointer 'meshPtr' to get to the actual
polymesh node?
Thank you,
Solved! Go to Solution.
Solved by Stephen.Blair. Go to Solution.
You can do things like AiNodeGetName( meshPtr )
Here's a snippet from MtoA:
defaultOperatorNode = ai.AiNodeGetPtr(ai.AiUniverseGetOptions(universe), "operator") defaultOperator = '' if defaultOperatorNode: defaultOperator = ai.AiNodeGetName(defaultOperatorNode)
Hmm, yes, I had tried that earlier, but got:
name = AiNodeGetName(meshPtr)
File "/usr/apps/arnold/arnold-5.1.0.1/python/arnold/ai_nodes.py", line 86, in AiNodeGetName
return AtPythonStringToStr(_AiNodeGetName(node))
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: expected LP_AtNode instance instead of int
Btw, we don't use Maya or MtoA, we have our own in-house node based editor 'Crom' (like Katana) and Arnold Core. Thanks
It worked for me (with the latest Arnold). I'll have to check through the release notes to see if there was a related fix.
With the attached ass file, this:
from arnold import * AiBegin() AiASSLoad("C:/Users/Stephen Blair/Documents/maya/projects/default/scenes/mesh_light_test3.ass", AI_NODE_ALL) iter = AiUniverseGetNodeIterator(AI_NODE_ALL) while not AiNodeIteratorFinished(iter): node = AiNodeIteratorGetNext(iter) if AiNodeIs(node, 'mesh_light'): meshPtr = AiNodeGetPtr(node, "mesh") print meshPtr print AiNodeGetName( meshPtr ) AiEnd()
Printed this:
<arnold.ai_nodes.LP_AtNode object at 0x00000000D2CC90C8> /pSphere1/light_pSphere1/light_pSphere1Shape@mesh
Ideally, would just like to keep using 5.1.0.1 for this job.. If there's a bug with that version for this, can you think of any alternative way to do this?
Thanks!