getSelectedFaces

I am writing a script that will set the mat index colour for the selected Faces.

I keep getting an error on the getSelectedFaces,

  1. what am I doing wrong ?
  2. Is there a way to get the current material index for the selected object ?
    a mesh may have more than one material i.e. 1 of 2, 2 of 2 as shown in the edit mode the Material dialog box ?
import Blender
from Blender import NMesh
from math import *
 
#me = NMesh.GetRaw("Plane")		# get the mesh data called "Plane"
#meFaces = me.faces				#get all the faces

meFaces = getSelectedFaces()	#get the selected faces

meFace = meFaces[0]

print meFace.mat
meFace.mat=0 
me.update()              # update the real mesh in Blender
import Blender
from Blender import NMesh
from math import *
 
me = NMesh.GetRaw("Plane")		# get the mesh data called "Plane"

#meFaces = me.faces			    #get all the faces
meFaces = me.getSelectedFaces()	      #get the selected faces

meFace = meFaces[0]

print meFace.mat
meFace.mat=0 
me.update()              # update the real mesh in Blender