// =========================================================================== // 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. // =========================================================================== // // File: ikUpdateSolverOptionMenuGrp.mel // // // Description: // // Procedure that updates a given optionMenuGrp field // with the list of available solvers. This list excludes // the "ikSplineSolver" which is a unique case that is // handled separately. // global proc ikUpdateSolverOptionMenuGrp( string $optMenuGrp ) { // FIREWALL: The $optMenuGrp must be an optionMenuGrp object. // if( !`optionMenuGrp -q -ex $optMenuGrp` ) { return; } // Check for new ikSolver nodes in the system and add them to // the optionMenuGrp if necessary. // string $solverNodes[] = `ikSystem -q -ls`; string $solverItems[] = `optionMenuGrp -q -ils $optMenuGrp`; int $nSolverNodes = size($solverNodes); int $nSolverItems = size($solverItems); // Set the current menu parent (make sure we retrieve // the fully qualified name) // string $currentParent = `setParent -q`; string $currentMenuParent = `setParent -q -m`; setParent $optMenuGrp; string $menuPath = `setParent -q`; string $optMenuPath = $menuPath + "|OptionMenu"; setParent -m $optMenuPath; string $nodeValue; string $menuItemValue; int $itemNum = $nSolverItems; int $i; for( $i = 0; $i < $nSolverNodes; $i++ ) { $nodeValue = $solverNodes[$i]; // Omit spline solvers // if( $nodeValue == "ikSplineSolver" ) continue; int $j; int $foundNode = 0; for( $j = 0; $j < $nSolverItems; $j++ ) { $menuItemValue = ikSolverUnlocalize(`menuItem -q -l $solverItems[$j]`); if( $menuItemValue == $nodeValue ) { $foundNode = 1; } } if( !$foundNode ) { // Create new menu item // string $item = `menuItem -l $nodeValue ($nodeValue + $itemNum)`; $itemNum++; } } setParent $currentParent; setParent -m $currentMenuParent; }