By John R. Gross, Autodesk (formerly Alias) Toronto Development Center.
In the course of a complex production, it’s possible that objects can get accidentally disconnected from their shaders. This script, findUnshadedObjects.mel, finds any unshaded objects, which can help you identify objects that have been accidentally disconnected from their shaders.
// // Copyright (C) 1997-2005 Alias Systems Inc. // // // The information in this file is provided for the exclusive use of the // licensees of Alias. Such users have the right to use, modify, // and incorporate this code into other products for purposes authorized // by the Alias license agreement, without fee. // // Alias DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO // EVENT SHALL Alias BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. // // Alias Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: 5/August/98 // // Author: jrg // // Procedure Name: // findUnshadedObjects // // Description: // This procedure examines all geometry in the scene, and reports any // that are not connected to any shading group. It returns the number of // such unconnected objects that were found. // It also reports (but does not include in the reported count) any objects // that are connected to multiple shaders. // global proc int findUnshadedObjects() { string $listOfShapes[] = `ls -geometry`; int $numShapes = size($listOfShapes); int $whichShape; string $shapeType[]; string $shaders[]; int $numShaders; int $numUnshaded = 0; for ($whichShape = 0; $whichShape < $numShapes; $whichShape++) { $shapeType = `ls -showType $listOfShapes[$whichShape]`; // // Skip over curves, as they are not rendered anyway. // if ($shapeType[1] == "nurbsCurve") { continue; } // // Get a list of all shading engines connected ’downstream’ // from this geometry. // $shaders = `listConnections -source true -type shadingEngine $listOfShapes[$whichShape]`; $numShaders = size($shaders); if ($numShaders == 0) { print("Object " + $listOfShapes[$whichShape] + "is not connected to any shading engine.\n" + "It will not show up when rendered.\n"); $numUnshaded++; } else if ($numShaders > 1) { print("Object " + $listOfShapes[$whichShape] + "is connected to " + $numShaders + "shading engines.\n"); } } return $numUnshaded; }
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License