View in #maya on Slack
@a772bNsz: so this neat line optimizes scene with all options enabled: pm.mel.cleanUpScene(3)
how can it skip âDisplay layersâ?
@bob.w: Is that an option in the scene cleanup command? If so youâd just need to decipher what flags to feed it. If not youâd probably need to copy/paste your own version of the command and make whatever changes are needed to skip that
@a772bNsz: ah. yea, thatâs an option
@bigroy: Try whatIs cleanUpScene
in mel.
Then check that file for the source MEL codeâŚ
Or have âEcho all commandsâ set in the Script Editor and then run the cleanup command with the settings you want from the UI. Big chance youâll see it get called in MEL with the arguments you need.
@bob.w: That is way better concrete advice than my driveby response!
@ldunham1: Theyâre all registered option variables
displayLayerOption
@a772bNsz: alrighty, so if I can identify all the corresponding optVar names, I can run like so:
pm.optionVar["shadingNetworkOption"] = 1
pm.optionVar["displayLayerOption"] = 0
...etc
pm.mel.cleanUpScene(2) # cleans up whatever is checked in the Optimize Scene UI```
unforunately echo all commands does not print what commands were used in optimize all. looks like some options are not functions
![ldunham1] **@ldunham1:** The header in cleanUpScene.mel says which functions are called if that helps.
You'll also be able to see the optionVars used looking at the ui builder procs in the same mel file;
global proc cleanUpSceneSetup
![a772bNsz] **@a772bNsz:** yea, I think I have them all
```optimize_scene_options = [
"nurbsSrfOption",
"nurbsCrvOption",
"unusedNurbsSrfOption",
"deformerOption",
"unusedSkinInfsOption",
"poseOption",
"clipOption",
"expressionOption",
"groupIDnOption",
"animationCurveOption",
"shaderOption",
"cachedOption",
"transformOption",
#"displayLayerOption",
"renderLayerOption",
"setsOption",
"partitionOption",
"locatorOption",
"ptConOption",
"pbOption",
"snapshotOption",
"unitConversionOption",
"referencedOption",
"brushOption",
"unknownNodesOption",
"shadingNetworksOption",
]
for option in optimize_scene_options:
pm.optionVar[option] = 1
@ldunham1: performCleanUpScene()
might be the command youâll want to run to preserve the optionVar states and not show the Ui
@a772bNsz: this opens the UI pm.mel.cleanUpScene(2)
my mistake
yea, performCleanUpScene()
is pretty much pm.mel.cleanUpScene(1)
except itâs giving me the prompt box
@ldunham1: You can also avoid the confirmDialog modifying MAYA_TESTING_CLEANUP environment variable (if needed)
Thats only avoidable with the given environment variable
os.environ[âMAYA_TESTING_CLEANUPâ] = 1
@a772bNsz: rats, I get a typeError
os.environ['MAYA_TESTING_CLEANUP'] = True
# Error: TypeError: file /Applications/Autodesk/maya2019/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/os.py line 473: putenv() argument 2 must be string, not bool # ```
oic, I didnât have this var created in the first place..
bingo `os.environ['MAYA_TESTING_CLEANUP'] = "1"`