Hi all,
I’m a bit lost (due to my lacks in python…).
I wrote a thermic plugin for architecture, with a part dedicated to ‘R’ calculation and attribution of A++,A+,A,B… labels.
Everything works almost fine (even external icons) but the ultimate goal would be to change the diffuse color of the material in function of this label(result).
At this stage I’m into a def draw, and the codes I’ve commented in the image always return me ’ Writing to ID classes in this context is not allowed’.
Does anyone have an idea on a workaround?
codes and test scene can be found here:
http://www.tmaes.be/web/fr/component/phocadownload/category/1-artoki.html?download=1:artoki-energy-0-0-7
I hope I’ve been understandable, thanks in advance!
–
tmaes
edit:
to be complete I also tried to pass by a button that edits all material slots with a color parameter(here is the class code where mat color is a material custom property):
def execute(self, context):
for i in bpy.context.active_object.material_slots:
#print(i)
print(i.material.diffuse_color)
print(i.material.mat_color)
i.material.diffuse_color[0]=i.material.mat_color[0]
i.material.diffuse_color[1]=i.material.mat_color[1]
i.material.diffuse_color[2]=i.material.mat_color[2]
return {‘FINISHED’}
it was nearly working, but it gave the same mat_color at every material slot…(didn’t understand why … object oriented things maybe)