Created
April 21, 2013 02:29
-
-
Save darkvertex/5428225 to your computer and use it in GitHub Desktop.
purge unused deformers
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
from time import clock | |
xsi = Application | |
def purgeUnusedDeformers(inColl): | |
c = clock() | |
for o in inColl: | |
if o.Envelopes.Count > 0: | |
env = o.Envelopes(0) | |
d = env.Deformers | |
w = env.Weights.Array | |
zeroWeightDeformers = [deformer.FullName for deformer, weights in zip(d, w) if not any(weights)] | |
n = len(zeroWeightDeformers) | |
if n > 0: | |
xsi.RemoveFlexEnvDeformer( o.FullName +';'+ ','.join(zeroWeightDeformers), False ) | |
xsi.LogMessage( 'REMOVED '+str(n)+' unused deformers from '+o.FullName ) | |
else: | |
xsi.LogMessage( 'There are NO UNUSED DEFORMERS in the envelope for %s' % o.FullName, 4 ) | |
xsi.LogMessage( "Took %s seconds to purge unused deformers." % (clock() - c), 16 ) | |
purgeUnusedDeformers(xsi.Selection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment