// =========================================================================== // 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: Sept 25 1997 // // Description: // This script looks for a visible model view to set to be the // current view. // // Input Arguments: // None. // // Return Value: // True if success. // // Note: // None. // global proc int findNewCurrentModelView() { global string $gMainPane; string $mainPaneCtls[]; string $visPanels[]; string $panelName; string $panelCtl, $edCtl; string $modelEd; int $nArr; int $i; int $newViewFound = false; // // First try to find something in the main pane. // if ($gMainPane != "") { string $newView = ""; $mainPaneCtls = `paneLayout -q -ca $gMainPane`; $nArr = size($mainPaneCtls); for ($i = 0; $i < $nArr; $i++) { $panelName = `getPanel -containing $mainPaneCtls[$i]`; if ("" != $panelName) { if ("modelPanel" == `getPanel -to $panelName`) { if (!`control -q -io $mainPaneCtls[$i]`) { $modelEd = `modelPanel -q -modelEditor $panelName`; if ("" != $modelEd) { // // If this view is already active, let's // continue to use it. // if (`modelEditor -q -activeView $modelEd`) { $newViewFound = true; break; } // // If this is the first eligable view that // we've found, save it. // if ($newView == "") $newView = $modelEd; } } } } } // // If we didn't find an already active view, but did find an // eligable one, make it active. // if (!$newViewFound && ($newView != "")) { modelEditor -e -activeView $newView; $newViewFound = true; } } // // Try to find any visible model panel // if (!$newViewFound) { $visPanels = `getPanel -vis`; $nArr = size($visPanels); for ($i = 0; $i < $nArr; $i++) { if ("modelPanel" == `getPanel -to $visPanels[$i]`) { $modelEd = `modelPanel -q -modelEditor $visPanels[$i]`; if ("" != $modelEd) { modelEditor -e -activeView $modelEd; $newViewFound = true; break; } } } } // // Try to find any visible model editor. // if (!$newViewFound) { string $eds[] = `lsUI -editors`; $nArr = size($eds); for ($i = 0; $i < $nArr; $i++) { if (`objectTypeUI -isType "modelEditor" $eds[$i]`) { $edCtl = `modelEditor -q -control $eds[$i]`; if ("" != $edCtl && "NONE" != $edCtl && !`control -q -io $edCtl`) { modelEditor -e -activeView $eds[$i]; $newViewFound = true; break; } } } } return $newViewFound; }