// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: May 22, 2003 // // // // // // int isParentOf(string $parent, string $child) // // // int : True if $parent is a DAG parent of the specified DAG object. // // // This procedure returns true if $parent is a DAG parent of the // specified DAG object, and false otherwise. // // See also firstParentOf(). // // // // Create a NURBS sphere. // // // string $createdNodes[] = `sphere -constructionHistory false`; // string $sphere = $createdNodes[0]; // // // Create a group containing a group containing the sphere. // // // string $group1 = `group`; // string $group2 = `group`; // // isParentOf($sphere, $sphere); // // Result: 0 // // // isParentOf($group1, $sphere); // // Result: 1 // // // isParentOf($group2, $sphere); // // Result: 1 // // // isParentOf("", $group2); // // Result: 0 // // // global proc int isParentOf(string $parent, string $child) { string $parentFullName = longNameOf( $parent ); string $childFullName = longNameOf( $child ); int $parentNameLen = size( $parentFullName ); int $isParent = false; // Check that parent is not empty but still shorted than the child full name if( ($parentNameLen > 0) && ($parentNameLen < size( $childFullName )) ) { // ensure that parent name s a prefix to the child full name $childFullName = substring( $childFullName, 1, $parentNameLen+1 ); if( $childFullName == ($parentFullName+"|") ) { $isParent = 1; } } return $isParent; } // === END OF FILE isParentOf.mel ===========================================