Checking Emission-Color if it matches


I have the following code:NewColor = [1,0,0,1]

GrundMaterialAussen =[“Lichtkügelchen Aussen.000”]
GrundMaterialInnen =[“Lichtkuegelchen Innen.000”]

MaterialGefunden = GrundMaterialAussen

Lichtkugel =[NameString]

if[0].node_tree.nodes[“Emission”].inputs[0].default_value != NewColor:

My problem is, that the if statement always returns false, even if the NewColor is like the existing color. For setting this color is no problem, it works[0].node_tree.nodes[“Emission”].inputs[0].default_value = NewColor

But to check it does not work!? How I have to put the if statment that it works?

Thank you very much for your help.

Try getting a list of the default_value:

mat_color = list([0].node_tree.nodes["Emission"].inputs[0].default_value)
if mat_color == NewColor:
    #do something here

I can’t say why it doesn’t work the other way, but this works.

Great, thank you very much.
I did it like this:

Color2 = MaterialSuche.node_tree.nodes[“Emission”].inputs[0].default_value
if str(Color2[:]) == str(varNeueFarbe):

I turned them in strings and then compared. But yours is much better :-).
It works great.

Thank you very much cmomoney