Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Created August 29, 2015 11:30
Show Gist options
  • Save SEVEZ/0d49f63879d2a4e24104 to your computer and use it in GitHub Desktop.
Save SEVEZ/0d49f63879d2a4e24104 to your computer and use it in GitHub Desktop.
Iterate through all the shells of mesh
from pymel.all import *
def getShellFaces( poly, str = 0 ):
shells = set()
faces = set()
total = polyEvaluate( poly, s=1)
for f in xrange( polyEvaluate( poly, f=1 ) ):
if len( shells ) >= total:
break
if f in faces:
continue
shell = polySelect( poly, ets=f )
faces.update( shell )
if str:
val = "%s.f[%d:%d]" % ( poly, min( shell ), max( shell ) )
else:
val = min( shell )
shells.add( val )
return list( shells )
poly = ls( sl=1 )
# get the first face of each shell to be selected
# later with polySelect
faceIds = getShellFaces( poly )
for f in faceIds:
polySelect( poly, ets=f )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment