Getting data for an object


I am wondering if there is a way to set data or properties about individual faces within a cube mesh. For example, the following code with get the cube in the scene and get its mesh data and I can access the faces and properties for the mesh, but it only prints out “[ID Property]”

obj = Object.Get('Cube')
me = obj.getData(mesh=1)
object = me.faces
props =
verts = me.vertices
print props

Is there a way to add properties to a face or the mesh itself outside the game properties?


I don’t think you can add properties to individual faces, but you can add properties to objects, materials, meshes, etc.
Here’s an example script for Blender’s default scene (you were already very close):

import bpy

ob =['Cube']
me = ob.getData(mesh = True)['foo'] = 'bar'['test'] = 42

for p in
    print p,[p]

You can also watch and edit those properties manually, by running the “ID Property Browser” (you can find it in Blender’s help menu, top of your screen by default). When you run the browser, select “Meshes” in the second drop-down box and you’ll see the values set by the script.

More information can be found here (api), here (release notes), and here (developer’s page). The keyword you’re looking for is “ID properties”.