Created
September 17, 2012 17:06
-
-
Save justinfx/3738519 to your computer and use it in GitHub Desktop.
function for returning the selectable shells of a poly
This file contains 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 getShellFaces(poly, asString=False): | |
shells = set() | |
faces = set() | |
total = cmds.polyEvaluate(poly, s=True) | |
for f in xrange(cmds.polyEvaluate(poly, f=True)): | |
if len(shells) >= total: | |
break | |
if f in faces: | |
continue | |
shell = cmds.polySelect(poly, extendToShell=f) | |
faces.update(shell) | |
if asString: | |
val = "%s.f[%d:%d]" % (poly, min(shell), max(shell)) | |
else: | |
val = min(shell) | |
shells.add(val) | |
return list(shells) | |
poly = 'polySurface1' | |
# get the first face of each shell to be selected | |
# later with polySelect | |
faceIds = getShellFaces(poly) | |
for f in shells: | |
cmds.polySelect(poly, extendToShell=f) | |
# get the string name of the entire shell in the | |
# form of polySurface1.f[x:y] to be used with select | |
shells = getShellFaces(poly, True) | |
for f in shells: | |
cmds.select(f) |
Just what I needed. Thanks Justin.
@sickiziu, as each face is extended to a group and then added to a set, this should work for all scenarios.
Thanks! should be like this I assume.
faceIds = getShellFaces(poly)
for f in faceIds:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello!
what if faces are not numbered in ascending order? what if faces 0, 3, 5, and 7 compose into shell?