Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using Python API to get mesh_light info

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
jpolkVFNE7
459 Views, 6 Replies

Using Python API to get mesh_light info

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,




Tags (2)
Labels (2)
6 REPLIES 6
Message 2 of 7
Stephen.Blair
in reply to: jpolkVFNE7

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)




// Stephen Blair
// Arnold Renderer Support
Message 3 of 7
jpolkVFNE7
in reply to: Stephen.Blair

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

Message 4 of 7
jpolkVFNE7
in reply to: Stephen.Blair

Btw, we don't use Maya or MtoA, we have our own in-house node based editor 'Crom' (like Katana) and Arnold Core. Thanks

Message 5 of 7
Stephen.Blair
in reply to: jpolkVFNE7

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




// Stephen Blair
// Arnold Renderer Support
Message 6 of 7
jpolkVFNE7
in reply to: Stephen.Blair

hmm, dang, yes, this job is still on 5.1.0.1, we have more recent versions online, 5.2.2.0, 5.4.0.2, and 6.0.1.0 but we've not fully tested in production 6.0.1.0.

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!




Message 7 of 7
jpolkVFNE7
in reply to: Stephen.Blair

Okay, just found that this works in 5.4.0.2

Thanks!



Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report