Applying materials

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Posts: 8
Joined: Tue Jul 15, 2003 3:20 am

Applying materials

Postby Rinkhals » Tue Jul 15, 2003 3:27 am


I need to apply material to various Meshes that I have managed to program Blender to construct.

mesh.addMaterial() would have been what I wanted, but it appears to be broken.

Can you add Textures and patterns to meshes/faces?

Can you control colour/emit parameters?

many thanks,


Posts: 1000
Joined: Tue Feb 25, 2003 2:37 pm

Postby ideasman » Wed Jul 16, 2003 12:33 pm

I just posted the same question on elysiun.
The answer is from illian Padovani Germano <> (now a Major Dude in my books)

Hi, your email was forwarded to me by Michel

.addMaterial() is a Mesh function, not NMesh. With NMesh the
list is in the nmesh member var .materials.

This should work:
import Blender
from Blender import Material, NMesh
m = material.New("newmat")
m.rgbCol = (1.0, 0.0, 0.3)
me = NMesh.GetRaw("Plane") # considering the default plane
me.materials.append(m) # here is the way to assign materials in NMesh

# now to put this mesh on a new object:

newme = NMesh.PutRaw(me, "newPlane")

# or to simply update the "Plane" mesh, comment the line
above and
# uncomment this one:

# me.update()

Any problem, feel free to email me or the bf-python list (where you
to be a member to be able to send emails):

Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests