import maya.OpenMaya as OMimport math
def faceCenter(): faceCenter = []
selection = OM.MSelectionList() OM.MGlobal.getActiveSelectionList(selection) print ("Number of objects in selection: %s " % selection.length())
iter = OM.MItSelectionList(selection, OM.MFn.kMeshPolygonComponent)
while not iter.isDone(): dagPath = OM.MDagPath() component = OM.MObject()
iter.getDagPath(dagPath, component)
polyIter = OM.MItMeshPolygon(dagPath, component)
while not polyIter.isDone(): center = OM.MPoint center = polyIter.center(OM.MSpace.kWorld)
#method A. (works fine)
point = [center.x, center.y, center.z] faceCenter += point # <<< works fine
#method B. (makes it run into an infinite loop / memory leak)
#faceCenter += center
polyIter.next()
iter.next()
return faceCenter--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a8d10aae-31a4-4134-b4c7-e28c593d205d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
A nice one!
have a look at these:
def faceCenter():
faceCenter = []
I suppose it is not really a good idea to name the function exactly like a variable.
haggi
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
On May 29, 2014 7:42 AM, <ha...@haggi.de> wrote:
>
> A nice one!
>
> have a look at these:
>
> def faceCenter():
>
> faceCenter = []
>
> I suppose it is not really a good idea to name the function exactly like a variable.
>
Unless you don't care about making recursive calls withing the function.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4f99ccdc07d5f05571d6617b9867bf90%40haggi.de.