Ok... well, I can now see why you're confused about the need for MIt*
types, if your primary point of reference is MSelectionList vs.
MItSelectionList.  For most MIt*s, there either isn't another class that
allows you to iterate through all objects of that type (ie,
MItDependencyGraph
<http://help.autodesk.com/cloudhelp/2015/ENU/Maya-SDK/cpp_ref/class_m_it_dependency_graph.html>),
or it provides many methods / ways of querying information that isn't
available through other function sets (ie, MItMesh*).

 The line is a bit blurred with MSelectionList / MItSelectionList, I feel
like.

It's made even more confusing because of two outstanding bugs / limitations
with MSelectionList / MItSelectionList, that frequently mean you need to
use BOTH. From the docs,
http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__files_Appendices_Appendix_E_API_and_Devkit_limitations_htm
(which
ALSO seem to have a bug - I have to browse through the contents tree, "Maya
Developer Help" > "Appendices" > "Appendix D: API and Devkit limitations",
in order to get the page to show up - maybe because the index says "D" but
they page title is "E"?):

Selecting multiple types of object components

When multiple types of object components are selected, e.g. edges and
vertices, an MSelectionList that has been assigned the active selection
list will contain only the final type of component selected. For example if
edges were selected and then vertices were shift-selected the
MSelectionList representing
the active selection list will contain one MObject representing the vertex
components.

Workaround

MItSelectionList list will differentiate between the different components
selected and can be used to identify all of the various components selected.
MItSelectionList::getDagPath()

MItSelectionList::getDagPath() will always return the original dagPath of
an instanced node. For example, if two shape nodes are selected and their
dagPaths are:

pCube1|pCubeShape1
pCube2

pCube2|pCubeShape1

getDagPath() will return:

pCube1|pCubeShape1
pCube1

pCube1|pCubeShape1

for each object in the list.

Workaround

MSelectionList::getDagPath() will return the correct dagPath for each
object in the list.


So - the summary is, if you only want the dag paths, you'd best use
MSelectionList... but if you want components, it's better to use
MItSelectionList... and if you want BOTH, then you have to use both.
 (Lame, I know!)



On Mon, Sep 22, 2014 at 9:07 AM, <[email protected]> wrote:

> Hey Justin, thx for replying.
>
> I think it's mainly just the iterators that I'm not really clear on.  The
> docs seem to hit on the function sets, but I'm not really finding anything
> that explains iterators in detail, maybe Im missing it?
>
> so would you use a function set to access points of a polymesh, then use
> an iterator to iterate through each point? is there a common direct useage
> between the function sets & iterators? or is it just case by case?
>
> anyhow. I'm working with the 2.0 python api right now, since I just
> noticed yesterday that quite a few more classes were added with sp4.
>
> With the code below, which would be the proper way to write it?  I feel
> like the first way is best.  what does the iterator really contribute?
> speed? am I even using the iter correctly? ;)
>
> #=======================================
> import maya.api.OpenMaya as om2
>
>
> selList = om2.MSelectionList( om2.MGlobal.getActiveSelectionList() )
> dagList = om2.MSelectionList()
> for i in range( selList.length() ):
>     dagList.add( selList.getDagPath(i) )
> print dagList
>
> #=======
>
> selList = om2.MSelectionList( om2.MGlobal.getActiveSelectionList() )
> selIter = om2.MItSelectionList( selList )
> dagList = om2.MSelectionList()
> while not selIter.isDone():
>     dagList.add( selIter.getDagPath() )
>     selIter.next()
> print dagList
>
> #=======================================
>
> Thanks!
> Kev
>
> --
> 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/6ed87828-bc64-4f4c-8774-312039ae7d9a%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/CAAssL7ZbroHni1CO-dXA%3DtRMfDUw3vJRy985CVV0gNPnE3d%2BKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to