作者:John R. Gross,Autodesk(以前的别名)多伦多开发中心。
在复杂的制作过程中,对象可能会意外与其着色器断开连接。该脚本 findUnshadedObjects.mel 可查找任何未经着色的对象,从而有助于您识别已意外与其着色器断开连接的对象。
// // 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; }