It would seem your intuition about getting the transform nodes was
right: try running this:

http://pastebin.com/f2d0d95a5

import maya.OpenMaya as OM
import maya.cmds as cmds

def printGeo():
    # creates the selection
    geoMSelectionList = OM.MSelectionList()
    OM.MGlobal.getSelectionListByName("*", geoMSelectionList)
    iterate=OM.MItSelectionList(geoMSelectionList,OM.MFn.kSurface) #
in my selection iteration I want to filter on the kMesh or
kNurbsSurface


    # this is the code to print out the selection list and the api
type of each filtered object in the selection
    fnDagNode=OM.MFnDagNode()
    objMObject=OM.MObject()
    selStrings =[]
    iterate.reset()
    while (not iterate.isDone()):
        iterate.getDependNode(objMObject)
        fnDagNode.setObject(objMObject)
        iterate.getStrings(selStrings)
        print "sel strings:", selStrings
        print(fnDagNode.fullPathName()+" ("+objMObject.apiTypeStr()+")")
        iterate.next()

cmds.file(new=1, f=1)
cmds.polySphere()
cmds.sphere()

printGeo()

Even though it returns the same MObject, the selection strings
indicate one is grabbed from the transform.

According to the docs, it's intended behavior to search below the
transform when there's a filter:

"If a filter is specified then the children of DAG selection items
will be searched if the selection item does not match the filter. For
example, if filter = MFn::kNurbsCurve and a transform is selected then
the underlying shape for the transform will be in the iteration if it
is a nurbs curve."

Seems non-intuitive to me too...

- Paul

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to