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
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
@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
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 = [
for option in optimize_scene_options:
pm.optionVar[option] = 1
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
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"`