Community
Arnold for Cinema 4D Forum
Rendering with Arnold in CINEMA 4D using the C4DtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C4Dtoa: Query User Data Nodes using Python

4 REPLIES 4
Reply
Message 1 of 5
Shawn_Kearney1
306 Views, 4 Replies

C4Dtoa: Query User Data Nodes using Python

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.

Tags (1)
Labels (1)
4 REPLIES 4
Message 2 of 5

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).

Message 3 of 5

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

Message 4 of 5

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/

Message 5 of 5

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 🙂

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

Post to forums  

Autodesk Design & Make Report