- 1.For ShaderNodeValToRGB, how can I get color_ramp on the node by Python API suppose I do not know it is ShaderNodeValToRGB? I want to automatically get the ShaderNodeValToRGB and its property color_ramp which can be changed on the node and ignore all other properties.
- 2.Same as above for ShaderNodeTexNoise, how can I get noise_dimensions and its value by API? I use ShaderNodeTexNoise.rna_type.properties to list all the property including noise_dimensions, but I only want to list noise_dimensions and its values not including other properties which are not included on the node.
-
1$\begingroup$ Related: How to know the input / output sockets of a Node, without importing it into the project, with Python? $\endgroup$– Markus von BroadySep 23, 2022 at 9:16
-
$\begingroup$ Thank you! Will test now.~ $\endgroup$– DerekcbrSep 23, 2022 at 10:38
1 Answer
What I do when I don't know stuff is I create a sample so in this case an object with a material and ColorRamp node, open Python console and use it's Autocomplete function (Tab) to find out what stuff is available in the API.
So first I find the node and see what else is in it:
when I see something interesting, I explore that:
It seems like something called 'elements' might be a list of something so I try to access it's first element:
After I find that it has color I check it's values and compare it with my node and if I change the second color to red the values of element[1].color
also change so I found the color ramp:
You can also try changing stuff from Python Console: