Last active
September 7, 2017 17:48
-
-
Save SEVEZ/278fee98885207c68872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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