MEL How-To #41 | ||
| ||
How do I replicate the Frame Selected and Frame All hotkey functions in MEL?Maya's built-in command for this is viewFit. You will need the object(s) in the selection list to be able to frame only specific items in the view. For example, to "frame selected" only "pSphere1" in the current camera view: select -r pSphere1; viewFit; To "frame all" in the current camera view: viewFit -all; The internal MEL script that Maya calls with the ‘ This script takes care of the differences between the model views and the various editors/panels. These editors have their own commands for framing selected items. To conclude, the script command you would want to include in your scripts is:
// Frame selected only in panel under mouse pointer
fitPanel -selected;
// Frame all in panel under mouse pointer
fitPanel -all;
The ‘ Framing Control For Arbitrary Panels
Some of these steps are utilized in the " Examples Perspective Camera (or any Camera, really) Conveniently, we don't have to bother with the first two steps here. When dealing with a camera view you can use the 'viewFit' command which accepts the name of a camera.
HyperGraph
string $hyperGraphPanels[] = `getPanel -scriptType hyperGraphPanel`; // Result: hyperGraphPanel1 hyperGraphPanel2 //
string $mainHyperGraph = "";
for ( $panel in $hyperGraphPanels )
{
// Looking for the main HyperGraph panel
if ( "Hypergraph" == `scriptedPanel -q -label $panel` )
{
$mainHyperGraph = $panel;
break;
}
}
// Result: hyperGraphPanel1 //
Note: You use the same technique to frame the selected items in the HyperShade Editor. You would use the ‘ Graph Editor The Graph Editor is also a scriptedPanel:
string $graphEditors[] = `getPanel -scriptType graphEditor`; // Result: graphEditor1 graphEditor2 //
string $mainGraphEditor = "";
for ( $panel in $graphEditors )
{
// Looking for the main Graph Editor
if ( "Graph Editor" == `scriptedPanel -q -label $panel` )
{
$mainGraphEditor = $panel;
break;
}
}
// Result: graphEditor1 //
NOTE: All of this from Maya v2.5.1. No idea if any of this changed for v3.0 Related How-To's | ||
Copyright ©2005 by Bryan Ewert, maya@ewertb.com Maya is a Registered Trademark of Alias |