// =========================================================================== // 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: 19 Nov 2015 // // // Procedure Name: // fitPanelWithoutChildren // // Description: // Procedure to do a view fit the selected objects without their // children in the pane under the pointer or all panels. // // // Return Value: // None. // proc doFit(int $animate, string $panel, string $camera, int $applyAllPanels, string $toFrame[]) { if ($applyAllPanels) viewFit -animate $animate $camera $toFrame; else viewFit -animate $animate `lookThru -q $panel` $toFrame; } global proc fitPanelWithoutChildren ( int $animate, string $panel, string $camera, int $applyAllPanels ) { if ($applyAllPanels && !size($camera)) return; else if (!$applyAllPanels && !size($panel)) return; string $oldSelects[] = `ls -sl`; if (!size($oldSelects)) return; string $toFrame[]; int $count = 0; string $oldSelect; for ($oldSelect in $oldSelects) { // If $oldSelect is something like a polygon, e.g. "cube1", // then select "cubeShape1" instead of "cube1", in this way, // we can fit "cube1" without its children in the panel. if (`objectType -isa "transform" $oldSelect`) { string $shapes[] = `listRelatives -fullPath -children -type "shape" $oldSelect`; if (size($shapes) && size($shapes[0]) && `objectType -isa "shape" $shapes[0]`) { $toFrame[$count++] = $shapes[0]; continue; } } $toFrame[$count++] = $oldSelect; } doFit($animate, $panel, $camera, $applyAllPanels, $toFrame); }