// =========================================================================== // 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: Feb 20 1997 // // Description: // This script will update the specified panel arrangement to reflect // the current state of the panels in the main pane layout ($gMainPane). // // Input Arguments: // $whichNamedLayout: The panel arrangement to be modified. // // Return Value: // None. // // Note: // None. // global proc updatePanelLayoutFromCurrent( string $whichNamedLayout ) { global string $gMainPane; string $panelName; string $controlName; string $label; int $wh[]; int $nPanes; int $i,$n; int $exists; string $buffStr, $buffStr2;; string $kCameraFlagStr = "-cam[a-z]*[ ][^ ^;]*"; string $kFindPerspStr = "-cam `findStartUpCamera persp`"; string $kFindTopStr = "-cam `findStartUpCamera top`"; string $kFindSideStr = "-cam `findStartUpCamera side`"; string $kFindFrontStr = "-cam `findStartUpCamera front`"; string $pCam = `findStartUpCamera persp`; string $fCam = `findStartUpCamera front`; string $sCam = `findStartUpCamera side`; string $tCam = `findStartUpCamera top`; // check to make sure the specified arrangement exists // string $pConfig = `getPanel -cwl $whichNamedLayout`; if ($pConfig != "") { $exists = true; } else { $exists = false; } if (!$exists) { string $msg = (uiRes("m_updatePanelLayoutFromCurrent.kArrangeNotFound")); warning `format -s $whichNamedLayout $msg`; } else { if (`paneLayout -exists $gMainPane`) { $wh = `paneLayout -q -ps $gMainPane`; $nPanes = size($wh)/2; // // first do config string // string $configStr = ("global string $gMainPane; paneLayout -e -cn \"" + `paneLayout -q -cn $gMainPane` + "\" "); for ($i = 0; $i < $nPanes; $i++) { $j = $i+1; $configStr += ("-ps " + $j + " " + $wh[2*$i] + " " + $wh[2*$i+1] + " "); } $configStr += "$gMainPane;"; panelConfiguration -e -cfs $configStr $pConfig; // // Update the panels // string $panelType, $panelName, $label, $panelCreate, $panelEdit; int $isFixed[] = `panelConfiguration -q -if $pConfig`; int $nPanels = `panelConfiguration -q -np $pConfig`; for ($i = 0; $i < $nPanes; $i++) { switch ($i) { case 0: $controlName = `paneLayout -q -p1 $gMainPane`; break; case 1: $controlName = `paneLayout -q -p2 $gMainPane`; break; case 2: $controlName = `paneLayout -q -p3 $gMainPane`; break; case 3: $controlName = `paneLayout -q -p4 $gMainPane`; break; } $panelType = ""; $panelName = ""; $label = ""; $panelCreate = ""; $panelEdit = ""; if ("" != $controlName) { $panelName = `getPanel -containing $controlName`; if ("" != $panelName) { $label = `panel -q -label $panelName`; $panelType = `getPanel -typeOf $panelName`; $panelCreate = `panel -q -cs $panelName`; $panelEdit = `panel -q -es $panelName`; } // // Substitute dynamic camera function for top,persp,front,side panels. // if ("modelPanel" == $panelType) { if (localizedPanelLabel("Persp View") == $label) { if (`modelPanel -q -cam $panelName` == $pCam) { $buffStr = substitute ($kCameraFlagStr, $panelEdit, $kFindPerspStr); $buffStr2 = substitute ($kCameraFlagStr, $panelCreate, $kFindPerspStr); $panelEdit = $buffStr; $panelCreate = $buffStr2; } } else if (localizedPanelLabel("Top View") == $label) { if (`modelPanel -q -cam $panelName` == $tCam) { $buffStr = substitute ($kCameraFlagStr, $panelEdit, $kFindTopStr); $buffStr2 = substitute ($kCameraFlagStr, $panelCreate, $kFindTopStr); $panelEdit = $buffStr; $panelCreate = $buffStr2; } } else if (localizedPanelLabel("Side View") == $label) { if (`modelPanel -q -cam $panelName` == $sCam) { $buffStr = substitute ($kCameraFlagStr, $panelEdit, $kFindSideStr); $buffStr2 = substitute ($kCameraFlagStr, $panelCreate, $kFindSideStr); $panelEdit = $buffStr; $panelCreate = $buffStr2; } } else if (localizedPanelLabel("Front View") == $label) { if (`modelPanel -q -cam $panelName` == $fCam) { $buffStr = substitute ($kCameraFlagStr, $panelEdit, $kFindFrontStr); $buffStr2 = substitute ($kCameraFlagStr, $panelCreate, $kFindFrontStr); $panelEdit = $buffStr; $panelCreate = $buffStr2; } } } } if ($i < $nPanels) { panelConfiguration -e -rp ($i+1) $isFixed[$i] $label $panelType $panelCreate $panelEdit $pConfig; } else { panelConfiguration -e -ap false $label $panelType $panelCreate $panelEdit $pConfig; } } // // Remove any excess panels from the config. // for (; $i < $nPanels; $i++) { panelConfiguration -e -removeLastPanel $pConfig; } } } }