APi 2.5 assign material

Hi there!!
Someona could you help me please? How is it possibile to assign material color to an object.


Mar = bpy.data.materials.new('Mimmo')
rgbCol = [0.2,0.4,0.5]
Mar.rgbCol


I have try many combination…
Have you a suggestion…
Thanks in advance!!!:slight_smile:

This code adds a new material to the active object:

import bpy

Mar = bpy.data.materials.new('Mimmo')
rgbCol = [0.2,0.4,0.5]
Mar.diffuse_color = rgbCol

#remove next 3 lines to just add the material on the end
if bpy.context.object.material_slots.__len__() > 0:
    bpy.context.object.material_slots[0].material = Mar
else:
    bpy.ops.object.material_slot_add()
    bpy.context.object.material_slots[bpy.context.object.material_slots.__len__() - 1].material = Mar

Look at the Import Images To Planes script in the addons for ideas.