2

I am trying to make a script that scans through all the mesh objects in a Maya scene and returns objects that have no UV shells. I've written a script that works...it uses the command findUvShells, but apparently for this application that particular command is agonizingly slow.

Is there an OpenMaya way to do it, or a faster command to use? I used this script on one of our simpler characters...who has only 1 mesh object...and it took over a minute to tell me that there were no objects with 0 UV shells.

def FindObjectsWithNoUVShells():    
    ObjectsWithNoUVShells = []
    OldSel = mc.ls(sl=True)
    Geo = mc.ls(typ="mesh")
    for Obj in Geo:
        mc.select(Obj)
        AllUVSets = (mc.polyUVSet(Obj, q=True, allUVSets=True))
        UVSet = AllUVSets[0]
        if (findUvShells(uvSet=UVSet)[1]) == 0:
            ObjectsWithNoUVShells.append(Obj)
    mc.select(OldSel)

    return (len(ObjectsWithNoUVShells) > 0), ObjectsWithNoUVShells

FindObjectsWithNoUVShells()
mranim8or
  • 159
  • 2
  • 9

1 Answers1

1

Looks like the polyEvaluate command is what I was looking for. Its pretty much instant, for this.

def FindObjectsWithNoUVShells():
    ObjectsWithNoUVShells = []
    OldSel = mc.ls(sl=True)
    Geo = mc.ls(typ="mesh")
    for Obj in Geo:
        mc.select(Obj)

        if mc.polyEvaluate(uvShell=True) == 0: 
            ObjectsWithNoUVShells.append(Obj)
    mc.select(OldSel)

    return (len(ObjectsWithNoUVShells) > 0), ObjectsWithNoUVShell
mranim8or
  • 159
  • 2
  • 9