add material API change?

how can add material now with new API change in 626 ?

Thanks

I am working on my BlendText conversion to 2.5 and I have a few material routines. Maybe these can help? I am not sure if these are up-to-date with the recent API changes, however?


############################################################################
# Code for manipulating or creating materials.
############################################################################ 
def returnActiveMaterial(passedContext):
    mat = None
    try:
        object = passedContext.object
        mat = object.active_material
    except:
        pass
    return mat

def makeMaterial(name, diffuse, specular, alpha):
    mat = bpy.data.materials.new(name)
    mat.diffuse_color = diffuse
    mat.diffuse_shader = 'LAMBERT'
    mat.diffuse_intensity = 1.0
    mat.specular_color = specular
    mat.specular_shader = 'COOKTORR'
    mat.specular_intensity = 0.5
    mat.alpha = alpha
    mat.ambient = 1
    return mat

def setMaterial(ob, mat):
    me = ob.data
    me.add_material(mat)

tested in 626 and this line
me.add_material(mat) does not work anymore !

salutations

Here’s why

http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31597

me.materials.link(mat) works now on…

good call here

seems to be working again which is nice

now i got the other little snippet which also add some texture
from the snippet tut done only about 2 weeks ago

and now i get another error on texture like this one
47 sTex = bpy.data.textures.new(‘BumpTex’)

d/multi_material.py", line 47, in run
TypeError: MainTextures.new(): required parameter “type” not specified
location:<unknown location>:-1

any idea on how to make this work again?

and just in case are there a list of modifications like that so we can consult and modify our exsiting scripts?

Thanks and hope it stabilise soon!

Out of curiosity, do you ever look at the python api docs before posting these questions?

Like, for example, the page for MainTextures where it tells you what the ‘type’ parameter is all about?

yes i did a lot and lost i don’t kow how much time trying to figure out the formal description
plus all API changes it’s not easy to follow it !

and in any case i don’t understand how the stucture work yet
and wiht all the changes some wiki are updated some are not

when it stabilise and we get good tut on it may be it will be easier to find and understand things and by the way this is till new and not much doc available
but it’s gething better with time and hope it continues to improve

Thanks and happy 2.5

This has changed a lot lately so my question is this? Is materials.link(mat)
still valid or is it materials.append(mat). link command is still used in import_obj.py.
Thanks.

the new mat is workling in 626
don’t know for later then that

will test this weekend

for texture did not ahve time yet to test that again probably this weekend

salutations