シェーディングされていないオブジェクトを検索する
 
 
 

Autodesk(旧 Alias)Toronto Development Center、John R. Gross 作

複雑な制作を行っているとき、オブジェクトとシェーダの接続が切れる場合があります。以下のスクリプト findUnshadedObjects.mel はシェーディングされていないオブジェクトを検索するため、シェーダとの接続が切れたオブジェクトを識別するのに便利です。

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;
}