get pivot of editable poly selection

I need to get the center of my selection (an array of verts)

Doing the average of all the verts doesn't seem to yeild the result i'm looking for.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
roosterMAP's picture

NVM. figured it out.my loop

nvm. it works now. :)

roosterMAP's picture

for example, I created a cube

for example, I created a cube (100x100x100) at the origin. The verts were (50 50 50),(-50 50 50), (50 -50 50),...

I did their average and got [0,12.5,12.5]...

My first question, is an averaging of all the verts the operation on need, and if so, what am I doing wrong in the source?

(
	local theObject
	local theVerts
	local avgX
	local avgY
	local avgZ
	local myVector
	local temp
 
	theObject = selection[1]
	theVerts = polyop.getVertSelection theObject
	theVerts = theVerts as array
 
	for i = 1 to (theVerts.count - 1) do
	(
		avgX = (polyOp.getVert theObject theVerts[i]).x + (polyOp.getVert theObject theVerts[i+1]).x
		avgY = (polyOp.getVert theObject theVerts[i]).y + (polyOp.getVert theObject theVerts[i+1]).y
		avgZ = (polyOp.getVert theObject theVerts[i]).z + (polyOp.getVert theObject theVerts[i+1]).z
	)
 
	avgX = avgX / theVerts.count
	avgY = avgY / theVerts.count
	avgZ = avgZ / theVerts.count
 
	myVector=[avgX, avgY, avgZ]
 
	print myVector
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.