Hi!!
I have the following function.... the problem is that everytime it gives me always the same vertex for all the faces... it doesn't matter if I am passing to it poly.f[2] or poly.f[5] for example, it always get the vertices [0:3]....
anyone knows what might be the problem??
CODE
def centerOfFace(facet):
#find the vertices that define that face.
vertex = cmds.polyListComponentConversion(facet, ff=1, tv=1) ###THIS COMMAND IS GIVING ME HEADACHES
cmds.select(vertex, r=1)
vertexFlat = cmds.ls(sl=1, fl=1)
#find out how many vertices define that face
vertCount = len(vertexFlat)
print vertexFlat
#for each vertex go through and find it's world space position.
vertPositionSumX = 0.
vertPositionSumY = 0.
vertPositionSumZ = 0.
for a in range(0, vertCount, 1):
coordinate = cmds.pointPosition(vertexFlat[a], w=1)
vertPositionSumX += coordinate[0]
vertPositionSumY += coordinate[1]
vertPositionSumZ += coordinate[2]
centroidX = vertPositionSumX/float(vertCount)
centroidY = vertPositionSumY/float(vertCount)
centroidZ = vertPositionSumZ/float(vertCount)
return [centroidX, centroidY, centroidZ]
thanks in advance!!
lg,
Daniel