Maya scene cleanup

Programatic way to run Maya’s Optimize Scene Size standart utility

Running custom set of cleanup utilities using Pymel:

import pymel.core as pm

# Source cleanUpScene.mel
# to make scOpt_performOneCleanup available
pm.mel.source('cleanUpScene')

pm.mel.scOpt_performOneCleanup({
    'setsOption',
    'nurbsSrfOption',
    'partitionOption',
    'animationCurveOption',
    'deformerOption',
    'unusedSkinInfsOption',
    'brushOption',
    'shaderOption',
    'shadingNetworksOption'
    }
)

The original mel source can me found here on mac:

Maya.app/Contents/scripts/startup/cleanUpScene.mel