// =========================================================================== // 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. // =========================================================================== // // Description: // If a panel with the given label does not yet exist then this will // create the panel and check for an optionVar with the same name. // If the optionVar exists then it will eval the command that is // stored in it, which will initialize the panel to its last stored // state. If the optionVar does not exist then this will create it, // initialized to an empty string, so that it will be stored the // next time the settings are saved. // global proc string rememberViewportSettings( string $viewLabel, string $camera ) { string $localPanelLabel = localizedPanelLabel($viewLabel); string $panelName = `sceneUIReplacement -getNextPanel "modelPanel" $localPanelLabel`; int $resetView = `optionVar -q ResetModelViewsOnNewScene`; if ("" == $panelName) { global string $gMainPane; int $menusOkayInPanels = `optionVar -q allowMenusInPanels`; $panelName = `modelPanel -mbv $menusOkayInPanels -parent $gMainPane -label $localPanelLabel `; if ( `optionVar -exists $panelName` ) { // Don't bother loading the saved view settings if we're going to reset anyways if ( !$resetView ) { string $cmd = ("{int $menusOkayInPanels = " + $menusOkayInPanels + "; "); $cmd += ("string $editorName, $panelName = \"" + $panelName + "\"; "); $cmd += `optionVar -q $panelName`; $cmd += ("; }"); catch( `eval($cmd)` ); } } else { optionVar -sv $panelName ""; $resetView = true; } } else { modelPanel -edit -label $localPanelLabel $panelName; } if ($resetView) { resetModelEditor( `findStartUpCamera $camera`, $panelName ); } return $panelName; }