I want to find the center (by center I mean the default pivot position) of a selection of vertices coming from multiple objects in Maya. I thought it was the centroid but it seems that this does not returns the correct coordinates.
I selected four vertices, the two poles of each sphere. In red is the "center" of this vertices, where Maya place the default pivot, and in blue is the centroid as I computed it.
Either my computations are wrong or the center of the vertices is not the centroid, anyway these are clearly not the same coordinates. Here is my code:
loc = cmds.spaceLocator ()[0]
vtxList = cmds.ls (sl = True, fl = True)
vtxPosSum = [0, 0, 0]
for vtx in vtxList:
vtxPos = cmds.xform (vtx, q = True, ws = True, t = True)
vtxPosSum[0] += vtxPos[0]
vtxPosSum[1] += vtxPos[1]
vtxPosSum[2] += vtxPos[2]
barycentre = [vtxPosSum[0] / len(vtxList),
vtxPosSum[1] / len(vtxList),
vtxPosSum[2] / len(vtxList)]
cmds.xform (loc, ws = True, t = barycentre)
So my question is, how can I find the position of the default Maya pivot when selecting vertices from multiple polygons?
Thanks