// =========================================================================== // 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: April 1, 2003 // // // // // // string firstParentOf(string $dagObject) // // // string : The first DAG parent of the specified DAG object. // // // This procedure returns the name of the first DAG parent of the // specified object, if any. If the specified object has no parents, the // return value is "". // // // string $dagObject The object whose first DAG parent should be returned. // // // // Create a NURBS sphere. // // // string $createdNodes[] = `sphere -constructionHistory false`; // string $sphere = $createdNodes[0]; // // // Create a group containing the sphere. // // // string $group = `group`; // // // Use firstParentOf() to get the parent of the sphere. This should be // // the name of the group. // // // string $firstParentOfSphere = firstParentOf($sphere); // // if (isSameObject($group, $firstParentOfSphere)) print("// Success!\n"); // // Success! // // global proc string firstParentOf( string $dagObject) { // // Description: // This procedure returns the name of the first parent of the specified // DAG object. // string $parent = ""; if ($dagObject != "") { if (`objExists $dagObject`) { if (size(`ls -dagObjects $dagObject`) > 0) { string $parentArray[] = `listRelatives -parent -fullPath $dagObject`; if (size($parentArray) > 0) { $parent = $parentArray[0]; } } else // (size(`ls -dagObjects $dagObject`) == 0) { string $fmt = (uiRes("m_firstParentOf.kNotADAGNode")); error `format -s $dagObject $fmt`; } } else // (!`objExists $dagObject`) { string $fmt = (uiRes("m_firstParentOf.kNoDAGNode")); error `format -s $dagObject $fmt`; } } return $parent; }