Something like this could work.

MDag         = om.MDagPath()
mSelList     = om.MSelectionList()
mSelList.add( nodeName )
mSelList.getDagPath(0,MDag)
MPointArray   = om.MPointArray()
AverageCenter = om.MPointArray()
om.MFnMesh(MDag).getPoints(MPointArray,om.MSpace.kWorld)
for i in range(MPointArray.length()):AverageCenter += MPointArray[i]
AverageCenter = AverageCenter/MPointArray.length()

On Wed, Mar 11, 2009 at 3:37 PM, [email protected] <
[email protected]> wrote:

>
> Hello there,
>
> I've created a simple code to which takes a locator, and then
> dependant on the distance from this locator, crudly shatters objects.
> The closer to the locator, the more times the code loops through and
> shatters the object.
>
> My problem is that now these shards are created, I want to place a
> particle at the centre of them. I'd like to be able to itterate
> through the shard objects, selecting each face, then per face, select
> all vertices and work out the centre point of the face.
>
> I can then use these values to work out the centre point of the
> geometry its self by adding them together and dividing byt he total
> number of faces. If that doesnt work, then crudly work out min/max
> value and achieve the same goal but in a long winded process thats
> messy.
>
>
> How would I accomplish this?
> My API skills are very limited at current as im a newbie attempting to
> suss out Mayas inner workings :).
>
> A fellow student has suggested using the:
>
> maya.OpenMaya.MItMeshPolygon.getPoints() command. however, as im a
> newbioe, im not 100% clued up on the setup process that is required if
> any for this command, or how to manipulate it to do the above process.
>
> Thanks for any help you can offer.
> Russ.
> >
>

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

Reply via email to