// =========================================================================== // 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: // global proc int findPanelInConfiguration( string $panelConfiguration, string $panelType) // // Description: // Look for a specific panel type in a panel configuration. If the // panel configuration contains the panel then the index (0 based) // of the panel is returned. // // Arguments: // panelConfiguration - A panel configuration. // // panelType - A panel type. // // Returns: // The 0-based index of the panel if it is found in the panel // configuration. -1 is returned if the panel is not found. // { int $result = -1; string $createStrings[] = `panelConfiguration -query -createStrings $panelConfiguration`; string $panelTypes[] = `panelConfiguration -query -typeStrings $panelConfiguration`; string $buffer[]; for ($panelIndex = 0; $panelIndex < size ($panelTypes); $panelIndex++) { if ("scriptedPanel" == $panelTypes[$panelIndex]) { // Tokenize the panel creation string, looking for the -type flag // to determine the scripted panel type. // $type = ""; $tokenCount = tokenize($createStrings[$panelIndex], $buffer); for ($index = 0; $index < size ($buffer); $index++) { if ("-type" == $buffer[$index] || "-typ" == $buffer[$index]) { $type = $buffer[$index + 1]; break; } } if ("" != $type) { if ($panelType == $type || ("\"" + $panelType + "\"") == $type) { $result = $panelIndex; break; } } } } return $result; }