PDA

View Full Version : Size those panels


Gabester
06-11-2007, 04:46 AM
Hi All, I'd like to know how to get the size and centre position of a panel. You see, I wan to create a small button like window automatically on the bottom right hand corner of the view. I want that to update the position based on the panel that's selected.

I know how to make the window, I know how to get the view, but is it at all possible to get the width and height of the model panel that's currently selected so I can autoposition this thing?

Much Appreciated,

Gabe

brubin
06-11-2007, 01:21 PM
hi,
try this:

// get all visible panels
string $allVisPanl[] = `getPanel -vis` ;

// get the panel with focus
string $allVisPanl[] = `getPanel -wf` ;

// get the Panel under the Pointer
string $panlUP = `getPanel -up` ;

// guessing that the WindowName is composed
// of the panelName + "Window"
if( `window -ex ( $panlUP + "Window")` )
{
// if the window exists query
// width
int $W = `window -q -w ( $panlUP + "Window")` ;
// height
int $H = `window -q -h ( $panlUP + "Window")` ;
// top left corner
int $C[] = `window -q -tlc ( $panlUP + "Window")` ;
int $cx = $C[0] ;
int $cy = $C[1] ;
// move it some and scale it
window -e -tlc ($cx+50) ($cy+50) -w ($W-35) -h ($H+24) ( $panlUP + "Window");
}


HIH
s.

Gabester
06-12-2007, 05:38 AM
Hmm.. not sure what you're trying to do there. You've defined the $allVisPanl var twice, and if I execute the rest it just doesn't do it. Thanks for the try though.

brubin
06-12-2007, 07:33 AM
you got to work with me here...

yes, the one var is initialized twice, - just to explain what your options are.
you need to pick the one declaration that works for your problem.

the rest does work, but -again- it's only exemplary. i tested with scriptEditor and hypergraph, the 'getPanel'-bit returns the name of the panels, which are nested in window-layouts, if you work in tear-off panels as i do. fortunately the windows are named accordingly by autodesk, which is nice for a change, since it allows desperate hacks like this. :)

but,
since your seemingly looking for something else, i figured you may be working with the modelPanel themselves? (you got to be more specific, man!)
so if that is what you want to do, maybe this could be a pointer:

// there is a global maya-Var indicating the paneLayout of the mainUI
global string $gMainPane;

// there are methods of finding out which modelPanel/modelEditor
// is behind the index 1 that i'm refering here, but it would take this too far
// to explain; if you need to know, check:
// <your-maya-program-location>/MayaX.Y/scripts/others/findNewCurrentModelView.mel
//
// this would resize modelPanel1 to 30% of the available width
paneLayout -e -ps 1 30 30 $gMainPane ;


HIH
s.

CGTalk Moderation
06-12-2007, 07:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.