Hi Fredrik ,if you are working on maya 2017 you could use iterators, it 
should be faster/simplest
it = om.MItDag(om.MItDag.kDepthFirst,om.MFn.kMesh)
while not it.isDone():
fnMesh = om.MFnMesh(it.item())
        #do your stuff
it.next()
As far as I know, the python api 2.0 it hasn't iterators until maya 2017, 
or you could use standart maya api:
from maya import OpenMaya as om


El miércoles, 16 de noviembre de 2016, 12:33:29 (UTC+1), Fredrik Averpil 
escribió:
>
> I have this:
>
> import maya.api.OpenMaya as omimport maya.cmds as cmds
> for mesh in cmds.ls(type='mesh'):
>     selectionList = om.MSelectionList()
>     selectionList.add(mesh)
>     dagPath = selectionList.getDagPath(0)
>     fnMesh = om.MFnMesh(dagPath)  # got it!
>
> Is this the simplest/nicest way to iterate over all meshes and get the 
> MFnMesh object or how would you improve this?
>
> I’m asking primarily for readability purposes.
>
> Regards,
> Fredrik
> ​
>

-- 
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/0d51a540-0273-4b51-9ff8-68f04e327923%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to