How to use the AtEnum API?

How to use the AtEnum API?

AaronWPowell
Enthusiast Enthusiast
753 Views
2 Replies
Message 1 of 3

How to use the AtEnum API?

AaronWPowell
Enthusiast
Enthusiast

I'm trying to figure out how to use the AtEnum API, specifically so I can work with state shaders with the Python API. Are there any good references in either C++ or Python I can reference that show how to get/set enum values from an AtNode object?

0 Likes
Accepted solutions (1)
754 Views
2 Replies
Replies (2)
Message 2 of 3

AaronWPowell
Enthusiast
Enthusiast
Accepted solution

I figured it out after digging through the API a bit. This code snippet shows a basic solution.

 

from arnold import *

AiBegin()

shader = AiNode(None, "state_float")
entry = AiNodeGetNodeEntry(shader)
enum = AiParamGetEnum(AiNodeEntryLookUpParameter(entry, "variable"))
value = AiEnumGetValue(enum, "sx")

print(value) # prints out 0

AiEnd()
0 Likes
Message 3 of 3

AaronWPowell
Enthusiast
Enthusiast

I should also clarify...

 

This solution ^^ is great for accessing the EnumAPI, but it turns out all you need to do to set or get the enum value from something like a `state_float` node is to use `AiNodeSetStr()` or `AiNodeGetStr()`.

0 Likes