Archive for the ‘ Linux ’ Category

..:: Face Center Value ::..

for Maya developers … if any one want to find out the center value of a face then use this API method to get it .

for eg : if you want to constrain some object to the center of a face then its easy now to do check this

for better view click

def getFaceCenter(obj):
objList = OM.MSelectionList()
node = OM.MObject()
dgPath = OM.MDagPath()
objList.clear()
objList.add(obj)
objList.getDagPath(0, dgPath)
mmtrix = dgPath.inclusiveMatrix()
dgPath.extendToShape()
mobj = dgPath.node()
meshPoly = OM.MItMeshPolygon(mobj)
meshPoly.reset()
ctr = 0
faceNormalValue=[]
while not meshPoly.isDone():
mpoint = meshPoly.center()
mPointToMatrix = mpoint * mmtrix
currentFaceNormal=[mPointToMatrix.x,mPointToMatrix.y,mPointToMatrix.z]
faceNormalValue.append(currentFaceNormal)
meshPoly.next()
return(faceNormalValue)