[Closed] change wire colour by material ID
Hey guys,
Just a quick one, but I’m stuck, and my knowledge of scripting is very limiting!
Anyway, what I’m trying to do is change the wire colour of the object based upon the effects channel of the material applied to that object, kind of a quick visual way to see what objects are using the effects channels.
Anyway what I have so far is
for i in selection do
(
if i.material.effectsChannel = 1 do
(i.wirecolor = red)
)
but I keep getting this error
– Error occurred in i loop
– Frame:
– i: $Box01
– Type error: if-test requires BooleanClass, got: 1
Sorry I’m trying to learn as I go, but this has me stumped! Probably a 5 sec thing for you pros!
Any help much appreciated!
Deano!
it’s asking for a boolean class because you are asking if a variable can be compared to something else. So by asking the question “if the materialeffect channel EQUALS 1 then do balhdeblah” you are saying that you want the staement to evaluate to true or false.
However with a single equals sign, In your example you are trying to assign the value rather than querying the state with a true or false argument. you use single equals to assign a property, and double equals sign to make a boolean comparison between the two parts.
for i in selection do
(
if i.material.effectsChannel == 1 then i.wirecolor = red
)
If you wanted to perform a boolean comparison on everything except material channel 1, you could use the != comparator or prefix it with not
if i.material.effectsChannel != 1
if not i.material.effectsChannel == 1
would both evaluate to true if the channel was not 1!