0
$\begingroup$
  • 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.
$\endgroup$
2

1 Answer 1

3
$\begingroup$

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: enter image description here

when I see something interesting, I explore that: enter image description here

It seems like something called 'elements' might be a list of something so I try to access it's first element: enter image description here

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:

enter image description here

You can also try changing stuff from Python Console:

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot! Very helpful! $\endgroup$
    – Derekcbr
    Sep 24, 2022 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.