[Bf-python] OB button pushing, making material visible

nicolas bonnand nicolas.bonnand at wanadoo.fr
Wed Mar 24 23:46:49 CET 2004


Hello,

I try to understand Object, Texture and Material creation
but I'am stuck with the final step

1) In the following simple  script, I generate a simple mesh
with 3 vertices

2) Then I apply a textured material to this triangle

3 ) But, at the end, why  (??) do I need to manually push the "OB" button
("links material to object" ) to be able to see
the cloud texture of the triangle ???????

Isn't it the role of the setMaterials method
to link the material to the object ????

What method should I use to establish this link ?

I'm using blender 2.32.

I've studied the following documentation but couldn't find
a complete example with object+material+texture creation.
http://www.blender.org/modules/documentation/232PythonDoc/

Any help appreciated.

Regards

Nicolas

#------------------------------------
from Blender import Texture,Material,NMesh,Draw

#new mesh
me= NMesh.GetRaw()

#vertices
me.verts.append(NMesh.Vert(1.0,0.0,0.0))
me.verts.append(NMesh.Vert(1.0,1.0,0.0))
me.verts.append(NMesh.Vert(0.0,1.0,0.0))

#face 
f=NMesh.Face()
f.v.append(me.verts[0])
f.v.append(me.verts[1])
f.v.append(me.verts[2])

me.faces.append(f)
o=NMesh.PutRaw(me,"MY_OBJ",1)

#create texture
t=Texture.New("MY_TEXT")
t.setType('Clouds')

#create material
mat = Material.New("MY_MAT")

mat.setTexture(0, t,Texture.TexCo.ORCO,Texture.MapTo.COL)
o.setMaterials([mat])

# Here I'm obliged to push the OB button in order
# to be able to see the material on the triangle

# It's OK when I create only one triangle, but it becomes boring
# after the 1000th ...


#------------------------------------




More information about the Bf-python mailing list