On May 29, 2014 7:42 AM, <[email protected]> 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.

> haggi
>
> Am 2014-05-28 16:28, schrieb Nico Klaassen:
>>
>> import maya.OpenMaya as OM
>> import 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
>>
>> Hi there! First post!
>>
>> Based upon some code that I've found (in this group) about looping over
faces and getting their centers, I ran into the following problem.
>> I've highlighted 2 methods in the polyIter section where I try to store
the center as an MPoint.
>>
>> center is already an MPoint*, but apparently I'm not allowed to store
the point directly into a list. Anybody who can point out why this is?
Because it's an MPoint reference?
>>
>>
>>
>> --
>> 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 [email protected].
>> 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.
>
>
>
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/4f99ccdc07d5f05571d6617b9867bf90%40haggi.de
.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ggdDk3xj%3DLO%2B9dQnR78z%3D10YyZ83ZK-u4M7WuDA-LJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to