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.
Forum topic · General Scripting
By roosterMAP · 2013-12-16
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.
NVM. figured it out.my loop
roosterMAP · 2013-12-16
nvm. it works now. :)
roosterMAP · 2013-12-16
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
)