Maybe this will help:
verts = cmds.ls (sl=1, fl = 1)
numVerts = len(verts)
vertLocations = cmds.xform (verts,q=1, t=1) # list of all locations
numVertLocations = len(vertLocations) # 3x num verts
xIndex = 0
yIndex = 1
zIndex = 2

xTotal = yTotal = zTotal = 0
# Add x,y,z values of all the verts:
while xIndex < numVertLocations:
        xTotal += vertLocations[xIndex]
        xIndex += 3 # Every third index will be an x posn
while yIndex < numVertLocations:
        yTotal += vertLocations[yIndex]
        yIndex += 3
while zIndex < numVertLocations:
        zTotal += vertLocations[zIndex]
        zIndex += 3

# Average locations:
xAvg = xTotal/numVerts
yAvg = yTotal/numVerts
zAvg = zTotal/numVerts

On Nov 25, 9:34 am, wilsimar <[email protected]> wrote:
> Nice simple solution, I don't thought on it.
> On complex meshes to make two loops may be very slow. but thank you
> for your idea.
>
> On 23 nov, 21:16, Kamil Hepner <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi!
>
> > You are unable to rewrite the polyAverage command because it doesn't exist
> > in *.mel file. The best solution is to write own Plugin or pymel script,
> > which will be do the polyAverage, in one axis.
> > But there is also simple solution, but it's not exactly what you want, but
> > you can try it:
>
> > Let's say we have geometry named meshA:
> > Duplicate meshA -> meshADup
> > Do polyAverage on meshADup
> > Take the translateX of every vertex on meshADub and apply it to the
> > translationX of the same vertex on meshA.
>
> > Cya!
>
> > 2011/11/23 wilsimar <[email protected]>
>
> > > hi. I need create a averagevertex only in one axis. Someone have some
> > > tip, tutorial or code for share?
>
> > > I have some ideas, but not I sure on how to implement and what is
> > > better.
> > >  . calling the maya polyaveragevertex command with two axis locked.
> > > (how to lock individual vertex axis?)
> > >  . finding the polyaveragevertex formula and reimplement it on single
> > > axis. (where to find?)
>
> > > If someone can help me.... thanks
>
> > > --
> > > view archives:http://groups.google.com/group/python_inside_maya
> > > change your subscription settings:
> > >http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to