Basically I'm trying to get every material in every object inside a collection, then randomise its colors. Except, I get the AttributeError which goes "Writing ID classes in this context is not allowed" It returned "Shader Nodetree, NodeTree datablock, error setting NodeSocketColor.default_value"
I have no Python knowledge and less about Blender stuff, so here
import bpy
import random
for collection in bpy.data.collections:
if collection.name == "spect":
for object in collection.all_objects:
for material in object.data.materials:
print("v")
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
a = 1
nodes = material.node_tree.nodes
bsdf = nodes.get("Principled BSDF")
bsdf.inputs[0].default_value = (r, g, b, a)
This is probably pretty stupid to ask, but, lol.