// Copyright (C) 1997-2004 Alias Systems Corp.
// 
// 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:  May 16, 2003
//


source "removeDuplicateNetworksUtils.mel";


global proc removeDuplicateNetworks( string $importedNodes[] )
// 
// Description:
//	Compare each node in $importedNodes with every other node in the scene.
//	If the two nodes are found to be duplicates, any geometry connected to
//	the imported node's network will be assigned to the existing duplicate,
//	and the imported node's network will be deleted.
//
{
	if ( `optionVar -query removeDuplicateShadingNetworksOnImport` )
	{
		// shadingEngines are the root of shading networks
		string $rootType = "shadingEngine";
		// Store a list of all the imported shadingEngines
		string $importedEngines[] = `ls -type $rootType $importedNodes`;
		// Store a list of all existing shadingEngines
		string $existingEngines[] = findAllNodesOfType( $rootType, $importedNodes );

		// Actually remove the duplicate shading networks
		doRemoveDuplicateShadingNetworks( $importedEngines, $existingEngines );
	}
}
