How do I get the Color value from an RGB node with Python? I'm a seasoned programmer, but fairly new to blender and 3D-modeling in general. So to get an understanding of different properties I want to write  python scripts to create multiple renderings with different settings of various values.

In the example below I have figured out how to change the Volume Absorption Density, ex:

bpy.data.materials['MyMaterial'].node_tree.nodes['Volume Absorption'].inputs['Density'].default_value = 100


But not the RGB-node. It seems I cant even get the current values out of it. Some things I have tried:

bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.r
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.outputs['Color']


How do I get and set output values of the RGB-node in py python-script?
Welcome to Blender.SE, UlfR.

Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).

Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.



The property you seek seems to be outputs[0].default_value.

def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value


It is a bpy_prop_array by default, so you may want to convert it to a list.

float_values = list(def_rgb)