Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Last active September 7, 2017 17:48
Show Gist options
  • Save SEVEZ/278fee98885207c68872 to your computer and use it in GitHub Desktop.
Save SEVEZ/278fee98885207c68872 to your computer and use it in GitHub Desktop.
def getUVShells(shape, uvSet=None):
uvSets = cmds.polyUVSet(shape, q=True, allUVSets=True)
if not uvSet or uvSet not in uvSets:
uvSet = cmds.polyUVSet(shape, q=True, cuv=True)[0]
selectionList = om.MSelectionList()
selectionList.add(shape)
mDag = om.MDagPath()
selectionList.getDagPath(0, mDag)
meshFn = om.MFnMesh(mDag)
uvShellArray = om.MIntArray()
shells = om.MScriptUtil()
shellsPtr = shells.asUintPtr()
meshFn.getUvShellsIds(uvShellArray, shellsPtr, uvSet)
uvShells = defaultdict(list)
for i, shellId in enumerate(uvShellArray):
uvShells[shellId].append('{0}.map[{1}]'.format(shape, i))
return uvShells.values()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment