question

Jim Polk avatar image
Jim Polk asked ·

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,




pythonapi
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Stephen Blair avatar image
Stephen Blair answered ·

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



2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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!




0 Likes 0 · ·
Okay, just found that this works in 5.4.0.2

Thanks!



0 Likes 0 · ·
Stephen Blair avatar image
Stephen Blair answered ·

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)


2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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

0 Likes 0 · ·

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

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.