Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

C4Dtoa: Query User Data Nodes using Python

C4Dtoa: Query User Data Nodes using Python

Shawn_Kearney1
Not applicable
856 Views
4 Replies
Message 1 of 5

C4Dtoa: Query User Data Nodes using Python

Shawn_Kearney1
Not applicable

Is there a way to query the name, attribute and default value of a c4dtoa 'User Data' node in Python? I looked for a corresponding .h file for a solution, but found that these nodes appear to be defined by c4dtoa.mtl instead.

I'd like to iterate through the shader network extracting User Data nodes to create artist-oriented GUI elements such that multiple objects can have different looks using the same shader.

0 Likes
857 Views
4 Replies
Replies (4)
Message 2 of 5

peter.horvath6V6K3
Advisor
Advisor

Hi Shawn,

Yes, it's possible to query and modify the shader network via custom messages. Check out the documentation here: https://support.solidangle.com/display/A5AFCUG/Shader+Network+%7C+Python

There are some example scripts at the bottom of the docs.

Once you get the shaders you can check for the type like:

ARNOLD_SHADER_GV = 1033990
C4DAI_GVSHADER_TYPE = 200
C4DAIN_USER_DATA_RGB = 547120169

if shader.GetOperatorID() == ARNOLD_SHADER_GV and shader[C4DAI_GVSHADER_TYPE] == C4DAIN_USER_DATA_RGB:
# do something

Tthe node ids are in api/include/util/NodeIds.h. The parameter ids can be generated with a hash function which you find in the docs. For example hashid("user_data_rgb.attribute") or hashid("user_data_rgb.default"). You can use kick to list the available attributes (kick -info n user_data_rgb).

0 Likes
Message 3 of 5

Shawn_Kearney1
Not applicable

Thank you! I think this is exactly what I was after. I'll give it a go when I'm back on this project.

0 Likes
Message 4 of 5

Maxime_Adam
Not applicable

I made a custom wrapper around the current python api of c4dtoa, that make it way more easier to deal with. The projet is open source ,I did it initally for a custom made material converted but if it can help any other devs, it's welcome !
https://gr4ph0s.github.io/C4DToA_python_wrapper/

0 Likes
Message 5 of 5

Shawn_Kearney1
Not applicable

Very cool! Thank you! This makes things much easier. Unfortunately the project I was working on was postponed. But I'll keep it in mind 🙂

0 Likes