Hi Vincent,

Thanks for that, although I'm looking for something which will also work in
Maya 2015/2016. I might just stick with what I have. I guess I just feel
it's a bit odd that I need to create a list of objects (with one object)
from which I can extract the DAG path ... instead of just using the DAG
path directly from the "cmds.ls(type='mesh', )" command.

On Wed, Nov 16, 2016 at 8:40 PM vincent zaraek <[email protected]>
wrote:

> 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
> <https://groups.google.com/d/msgid/python_inside_maya/0d51a540-0273-4b51-9ff8-68f04e327923%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAD%3DwhWN553Q-4%2Baz4kc1iZ_-iaYZmqwtNJi2nuEUekCBZhJakw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to