File > Optimize Scene Size

 
 
 

Allows you to remove empty, invalid, or unused parts from the scene to reduce its size and complexity. You can perform a complete scene clean up, or you can choose to run individual optimizations.

Select File > Optimize Scene Size > and turn on or off the types of information to remove, or run individual types of optimizations.

A progress bar displays as Maya optimizes the scene. You can interrupt the operation by pressing . You get a report of all the results of the optimization in the Script Editor.

Optimize Scene Size options

The following information explains the cleanup operations performed by the various options in the Optimize Scene Size Options window.

Remove invalid values

NURBS surfaces + curves

Deletes invalid NURBS surface and curve nodes. A node is considered invalid when it has no connections. Specifically, this operation removes the following invalid nodes:

  • stitchSrf
  • rebuildSurface
  • insertKnotSurface
  • avgNurbsSurfacePoints

Remove empty

Sets

Deletes unused (empty) sets. Certain default set nodes are not removed by this operation. These set nodes are:

  • defaultLightSet
  • defaultObjectSet
  • initialParticleSE
  • initialShadingGroup
    Partitions

    Deletes unused (empty) partitions. A partition is considered unused when it does not have any connections to nodes in the rest of the scene.

    Transforms

    Removes transform nodes that have no relatives or connections, and are not associated with any referenced nodes.

    Display layers and Render layers

    Deletes empty display or render layer nodes that are not locked and are not part of a referenced file. Default layers are not deleted by either the Display layers or the Reference layers operation.

Remove unused values

Animation curves

Deletes animCurve nodes that have no connections to other nodes in the scene, are not locked, and are not from referenced files.

Animation clips

Deletes source animation clip and animation clip nodes that are not being used in the scene. An animation clip is considered unused when it is not associated with a character set in your scene, and when it is not connected to any other scene nodes. A source clip node is considered unused when there are no used animation clips in the scene linked to that source clip.

Poses

Deletes all animation poses that are not applied to a character in your scene.

NURBS curves

Deletes NURBS curves that have no connections to other nodes in the scene, that are not locked, not from referenced files, and whose parents are not in use. If the NURBS curve has a parent with connections to other scene nodes, then the curve will not be deleted.

NURBS Surfaces

Deletes NURBS surfaces that are identical to their respective input NURBS surfaces. When a NURBS surface’s only input connection is to create, when the surface is input connected to another NURBS surface with the same parent, and when the surface is the same shape as its input, this operation will remove the NURBS surface. For example, if you rebuilt a NURBS sphere, but the settings of the rebuilt surface were identical to the original input surface, the rebuilt sphere would be deleted.

Note that in order for this operation to remove a NURBS surface, the surface cannot be locked, or from a referenced file.

Cached data

Even though dependency graph values are computed or dirty, they may still occupy space temporarily within the nodes. This cleanup operation goes into all of the data that can be regenerated if required and removes it from the caches (datablocks), thus clearing up space in memory.

Deformers

Deletes unused deformers with no output connections, as well as intermediate objects with no output connections.

Unused skin influences

Removes any joints or influence objects that have no effect on the skin (i.e. all weights are 0.0).

Expressions

Deletes all expression nodes which have no direct connections to their output attributes. An expression with a direct connection creates a relationship between an output attribute and input attribute in the scene. In other words, an expression that is part of a connected group of nodes not linked to the rest of the scene will be deleted, because the expression does not reference output attributes associated with the scene. Unit nodes with nothing on the other side are not evaluated, and therefore, are not deleted by this operation.

This operation only deletes expression nodes, and not dynExpressions, which are built into particle shapes.

Warning

If you have an expression that executes MEL commands but has no direct connection to an output attribute (output connection), this operation will delete that expression.

GroupID nodes

Deletes all GroupID nodes that have no connections to other nodes in the scene, are not locked, and that are not from referenced files.

Rendering nodes

Deletes all unused Rendering nodes. This procedure progresses through three stages:

Stage 1

Deletes empty shading groups, as well as shading groups that have no connected surface, volume, or displacement shaders.

Stage 2

Deletes all material nodes (surface, volume, displacement shaders) whose outputs are not connected to anything. Output connections from message attributes do not indicate that the node is in use, so nodes with only this type of output connection will be deleted. Note that this stage will delete shaders that were feeding into empty shading groups. Stage 1 deleted the shadingEngine node for empty shading groups, which leaves the materials that were feeding into empty shading groups disconnected. These disconnected materials will now be deleted.

Stage 3

Deletes all unused texture and utility nodes. Nodes are unused if they have no relevant output connections. Note that the textures and utilities feeding into the deleted materials from stage 2 will now be deleted.

Locators

Deletes locator objects that do not have connections to their shapes or to their transform nodes. If the locator has a parent with connections, or if the locator has a parent node with more than one child, the locator will not be deleted. Only locators that are not locked and not from referenced files will be removed by this procedure.

Constraints

Deletes constraints that are not constraining any objects. In other words, this procedure removes constraints that are not driving anything, and that do not have any output connections. In order for a constraint to be deleted by this procedure, the constraint cannot be from a referenced file, and it cannot be locked.

Specifically, this procedure evaluates the following nodes in your scene to determine whether or not they should be removed:

  • pointConstraint
  • aimConstraint
  • orientConstrain
  • parentConstrain
  • scaleConstraint
  • normalConstraint
  • tangentConstraint
  • geometryConstraint
    Pair blends

    Deletes pairBlends that have no outputs, or pairBlends that have no connections to input2. A pairBlends node that is locked or from a referenced file will not be removed by this procedure.

    Snapshot nodes

    Deletes all Snapshot nodes that have one connection or fewer to the rest of the scene. A Snapshot node that is locked or from a referenced file will not be removed by this procedure.

    Unit conversion nodes

    Deletes all unit conversion nodes that have one connection or fewer to the rest of the scene. A unit conversion node that is locked or from a referenced file will not be removed by this procedure.

    Referenced items

    Deletes all referenced nodes not used by the scene or the scene’s references. This operation will not delete nodes that are read-only.

    Brushes

    Deletes all brushes that are not attached to any strokes. This can be used to clean up default brush nodes that may accumulate when doing a large number of import operations.

    Unknown Nodes

    Deletes all of the following node types:

  • unknown
  • unknownDag
  • unknownTransform

Remove duplicate values

Shading networks

Compares each shading network to the other shading networks in the scene, and collapses duplicate shading networks into one. Duplicate shading networks will be deleted in alphabetical order, based on shadingEngine node name. To collapse all duplicate networks into a particular network, rename that network so that it is last in the alphabetical ordering of shading networks in the scene.

Customizing the Optimize Scene Size Operation

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

When you open the script, you will 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. These functions are as follows:

Registering 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 of Maya.

Configuring 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.

Viewing attributes of user-defined 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.

Running user-defined cleanup operations

userCleanUp_PerformCleanUpScene()

Called to actually perform the user-defined optimize scene operations that are currently enabled (via their optionVars). Returns the number of errors (if any) that occur when invoking the operation.

Related topics