The nice thing about using pymel is that it returns objects that usually
support common operations in a more intuitive form.So in this instance
meshFace.getPositions() returns a list of pymel Vector objects, which
support operations such as addition, scalar division and multiplications (so
you don't need to go element by element, x-y-z)

from pymel import *
v1 = Vector([1,2,3])
v2 = Vector([2,3,4])

print v1 + v2
print v1 * 2
print v2 / 2

Google up info about the built-python in function 'reduce' and the 'add'
function from the built-in 'operator' module you'll see how those two
together can take a list of objects and add them all up together... divide
the result by a scalar value and you've essentially calculated the centroid
of a list of Vectors.





- Ofer
www.mrbroken.com


On Wed, Jun 3, 2009 at 10:14 AM, Dimitry <[email protected]> wrote:

>
> ok i got it
>
> for item in arrCount:
>        objFace=arrMesh.getPolygonVertices(arrCount[item])
>        pt1=arrMesh.vtx[objFace[0]].getPosition()
>        pt2=arrMesh.vtx[objFace[2]].getPosition()
>        centerPt=[ (pt1.x+pt2.x)/2,(pt1.y+pt2.y)/2,(pt1.z+pt2.z)/2 ]
>
> thank you Ofer and Chad for great support!
> Best!
> Dimitry
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to