set Material?


(2abstract4u) #1

Hi !

how do i set a metrial in python !?

i just get it work with the texture channel (texture= pure color), but there must be a way to do it easily.

so e.g. i got 3 materials and a mesh object and want to change the material using python !

PLZ Help !


(uaraus) #2

Hi
what I do (and works for me) is:



obj = Blender.Object.Get('NameOfObject')

if obj.getType() == 'Mesh':
    msh = obj.getData(False)
    mat = Blender.Material.Get('NameOfMaterial')  #or create new and tweaks settings
    msh.addMaterial(mat)


I’m in a hurry, so maybe some calls are misspelled, but the general sense is clear and you can always refer to the API doc.
Hope this helps
Bye


(2abstract4u) #3

thanxx i´m tryin with this :

    me = NMesh.GetRaw("Arm")
    mat = me.materials[1]  
    mat.R=0.55;mat.G=0.3;mat.B=0.4;

but here i have to put the color in!

will try your version