I am trying to read the color from an HSV-Node via the scripting api. This is my material shadernodes tree (simple test scene, no other materials etc). I have confirmed that the HSV node is correctly connected to the "Base Color" input of the Principled BSDF, and changes to the Hue/Saturation/Value sliders change the appearance of the default cube using this material.
Why does this simple test script return [0,0,0] for the color? I expected it to be anything else? It correctly confirms that the color is coming from an input, but the color value (black) seems to be wrong.
I can reproduce the problem in Blender 3.6 and 4.0. Other nodes that output a color also produces 0,0,0,0 as value. Windows 11.
import bpy
# Get the active material
material = bpy.context.active_object.active_material
# Assuming your PrincipledBSDF node is named "Principled BSDF" in the Shader Editor
principled_bsdf_node = material.node_tree.nodes.get("Principled BSDF")
# Get the input node connected to the base_color socket
base_color_source = principled_bsdf_node.inputs['Base Color'].links[0].from_socket
# Check if there's a connected node
if base_color_source:
# Get the output value from the connected node
print("getting color via input")
base_color = list(base_color_source.default_value)
else:
# If no connected node, use the local color of the PrincipledBSDFWrapper
print("getting local color")
base_color = list(principled_bsdf_node.inputs['Base Color'].default_value)
print(f"Base Color of material {material.name}: is {base_color}")