Create a custom Optimize Scene Size operation

You can edit the MEL script invoked by the File > Optimize Scene Size command to add your own cleanup operations to the Optimize Scene Size Options (File > Optimize Scene Size > ). The script is called cleanUpScene.mel, and you can find it in the /scripts/startup directory.

When you open the script, notice that there is a set functions defined near the end of the script to help you add and manage your own scene cleanup operations.

Register a new cleanup operation

cleanUp_AddUserCleanUp()

This function registers a new user-defined cleanup operation. This routine can actually be found in the userCleanUp_AddUserCleanUp.mel script, found in the /scripts/startup directory.

Configure a cleanup operation

userCleanUp_CreateUI()

Called to create the UI for user-defined cleanup operations. Each operation's UI consists of a checkbox to enable and disable the operation, and an Optimize Now button that can be used to execute only that operation.

userCleanUp_SetOptionVars( int $forceFactorySettings )

Called when the option variables for cleanup operations are either being initialized from scratch (at startup), or reset to factory settings. You can retrieve the appropriate default values and set the option variables accordingly.

userCleanUp_CleanUpSceneSetup( string $parent, string $forceFactorySettings )

Called when the Optimize Scene Size Options dialog is created, to synchronize the check boxes in that dialog with the values of the corresponding optionVars.

userCleanUp_CleanUpSceneCallback( string $parent, string $doIt )

Called when the current state of the checkboxes in the Optimize Scene Size Options dialog need to be saved as option variables.

View attributes of your cleanup operations

userCleanUp_GetNumCleanUps()

Returns the number of user-defined cleanup operations that have been registered. They are identified by numbers from 0..n-1.

userCleanUp_GetOptionVarName( int $cleanUpNum )

Returns the option variable associated with the specified user cleanup operation. The value of this variable indicates whether or not that particular operation will be performed the next time an Optimize Scene Size operation is invoked.

userCleanUp_GetDefaultValue( int $cleanUpNum )

Returns the default value (on or off) of the specified user-defined cleanup operation.

string userCleanUp_GetControlName( int $cleanUpNum )

Returns the name of the checkBox control group in the Optimize Scene Size Options dialog that is associated with the specified user cleanup operation. The state of this checkbox and the corresponding option variable (see userCleanUp_GetOptionVarName()) are synchronized when that dialog is created or destroyed.

userCleanUp_GetLabel( int $cleanUpNum )

Returns the text that should be used to label the specified user-defined cleanup operation in the Optimize Scene Size Options dialog.

userCleanUp_GetCommand( int $cleanUpNum )

Returns the command string that should be executed to perform the specified user-defined cleanup operation.

userCleanUp_ListCleanUps()

Prints a list of all registered user-defined cleanup operations.

userCleanUp_GetOptionVars()

Returns a list of all option variables associated with user-defined cleanup operations.

Run your custom cleanup operation

userCleanUp_PerformCleanUpScene()

Performs the custom optimize scene operations that are currently enabled with optionVars. Returns the number of errors (if any) that occur when invoking the operation.

Related topics