Removing render plugins from a Maya scene |
Having unused render plugins loaded into a Maya scene can lead to a number of fatal errors.
However it can be quite difficult to unload a render plugin once it has been loaded. The best method is to begin the texture
phase of production by ensuring that you are working with a clean scene with no unwanted plugins loaded. The sure fire way to do this
for a texture file (consisting only of grouped geometry) is: Removing plugins by exporting FBX
This works perfectly when dealing only with groups and geometry, however an FBX file will not retain materials or textures. In that case we need to use some MEL code. We begin by printing a list of all the plugins that are currently are loaded. This will be printed in the Script Editor output.
pluginInfo -query -pluginsInUse; You then find the name of the plugin you want to remove from the list you generated above, copy it and paste into the code below where it says PASTE_PLUGIN_NAME. This command will create a variable with the name of the render plugin we want to remove.
$pluginName ="PASTE_PLUGIN_NAME"; Next comes the hard part (made easy with a for-loop in MEL): We make a list of the nodes that plugin uses, unlock these and delete them one at a time, and then flush the undo queue.
string $nodeTypes[] = `pluginInfo -query -dependNode $pluginName`; string $type = ""; for ($type in $nodeTypes) { string $node = ""; string $nodes[] = `ls -type $type`; for ($node in $nodes) { lockNode -lock 0 $node; delete $node; } } flushUndo; We now print a list again of the plugins in use to see if the plugin we just removed is gone.
pluginInfo -query -pluginsInUse; Assuming it is no longer listed, we can now unload it.
unloadPlugin $pluginName; The above sequence of commands is repeated for each render plugin that you wish to remove. This works for removing Vray, Arnold, Renderman, Turtle, and really just about every render plugin from a scene... with one major exception: It does not work for removing MentalRay. Presumably this is because MentalRay is so deeply embedded into a Maya scene that it is neigh impossible to extract it once it has been loaded into a scene. In the case of MentalRay you will need to use the FBX method, which will mean that everything but groups and geometry will be lost. You could try to save the materials and textures by exporting these from the Hypershade into a new Maya scene, crossing your fingers, checking to see if that scene has Mental Ray loaded, and hoping you are lucky. Otherwise you will need to create the materials and assign the textures again. The moral of the story: Always make sure Mental Ray is not loaded when you begin working on a scene! Here are all of the above MEL commands all put together for your convenience:
//see what plugins are loaded. This will print a list of them. pluginInfo -query -pluginsInUse; //find the name of the plugin you want to remove and replace it here... $pluginName ="PASTE_PLUGIN_NAME"; //print $pluginName ; //make a list of the nodes that plugin uses... string $nodeTypes[] = `pluginInfo -query -dependNode $pluginName`; //unlock and delete them, and flush undo... string $type = ""; for ($type in $nodeTypes) { string $node = ""; string $nodes[] = `ls -type $type`; for ($node in $nodes) { lockNode -lock 0 $node; delete $node; } } flushUndo; //see if the plugin is still in use... pluginInfo -query -pluginsInUse; //finally, unload the plugin... unloadPlugin $pluginName;
|