View Full Version : GUI Help: Control to select attribute


lightwolf
09 September 2007, 09:46 AM
Hi there,

forgive me if I missed something here (I'm new to both Maya and MEL).

I need to allow the user to select a bunch of attributes via a GUI. Specifically a bunch of rotational axes (i.e. object.rotation, or object.rotation.x).

What would be the best way to approach this? I've tried attrNavigationControlGrp but that got me nowhere.

Thanks for any help!

Cheers,
Mike

Segmoria
09 September 2007, 12:26 PM
Try this:
attrFieldSliderGrp -min -180.0 -max 180.0 -at ("pCube1.rx");

lightwolf
09 September 2007, 12:47 PM
Try this:
attrFieldSliderGrp -min -180.0 -max 180.0 -at ("pCube1.rx");
Thanks... but that only displays the attribute. I want a way for the user to select an attribute (so that I can then use that internally as a source for my code).

Basically an attribute picker.

Cheers,
Mike

Segmoria
09 September 2007, 01:11 PM
So you want to prompt the user to select some attributes from a list? Why not use a textScrollList then where the user can also select multiple attributes?
Something like that maybe:

window;
columnLayout;
text "Atrributes";
textScrollList -numberOfRows 4 -allowMultiSelection true
-append "rotationX"
-append "rotationY"
-append "rotationZ"
-showIndexedItem 1;
showWindow;

lightwolf
09 September 2007, 01:16 PM
So you want to prompt the user to select some attributes from a list?
Not quite... any attribute of an item.
Basically this is to control a motion control from within Maya, and the user should be able to select in the GUI which attribute drives which axes of the motion control.

Why not use a textScrollList then where the user can also select multiple attributes?
Something like that maybe:

I've had something similar to that using a pop-up menu, but that'll be hard to maintain if the scene changes.
I'm starting to think that this is the wrong methodology for Maya and it wasn't designed for what I have in mind. I could of course just use hard coded atributes.

*thinking*

But thanks a lot for your input!

Cheers,
Mike

Segmoria
09 September 2007, 01:29 PM
ok what if you prompt the user to select the attributes he wants from the channelbox and then use the selectedChannelBoxAttributes script to list which attributes he has selected
(this script returns a string array containing the current selected attributes from the channelbox).

Seems much simpler to me to do it that way, rather that create a UI and list all the attributes of each object there.

lightwolf
09 September 2007, 01:39 PM
ok what if you prompt the user to select the attributes he wants from the channelbox and then use the selectedChannelBoxAttributes script to list which attributes he has selected
(this script returns a string array containing the current selected attributes from the channelbox).
Thanks, that sounds like an approach that makes sense. And I could probably do that from a textFieldButtonGrp.

Seems much simpler to me to do it that way, rather that create a UI and list all the attributes of each object there.
Well, I was looking for something similar to the attrNavigationControlGrp, which opens a new window to select a node if you click on the button.

Cheers,
Mike

lightwolf
09 September 2007, 02:49 PM
In the end I decided for another approach. I'm creating an empty group with extra attributes and just let the user connect whatever they want exported to these.

Still, thanks a lot for the heads up!

Cheers,
Mike

Segmoria
09 September 2007, 03:27 PM
Whatever works best for you! Good luck with the rest!

lightwolf
09 September 2007, 04:01 PM
Whatever works best for you! Good luck with the rest!
Thanks. Wrapping my head around the SDK, Mel and Maya at the same time as working out a decent workflow surely is a daunting task. But I'm getting there...

Cheers,
Mike

xcomb
09 September 2007, 07:50 PM
Well i hope this is what you are looking for!
I specified -sl so you can select object to display them.
In GUI you can create anything like popUp menues and execute anything like key attributes or delete keys from selected attributes, so on.

if(`window -exists mainWindows`)
deleteUI mainWindows;

window -title "window" -wh 300 300 -mxb off mainWindows;
columnLayout -adj 1 mainCol;
textScrollList -w 300 -h 230 -ams 1 mainText;
button -l "Refresh" -c "refreshButton()" refButton;
button -l "Show Attributes" -c "attrButton()" attributeButton;
refreshButton();
showWindow mainWindows;

global proc refreshButton(){
textScrollList -e -ra mainText;
string $listObjects[] = `ls -l`;
string $relation[] = `listRelatives -p $listObjects`;

for ($each in $relation){
textScrollList -e -append $each mainText;
}
}

global proc attrButton(){
if(`window -exists attrWindow`)
deleteUI attrWindow;
window -wh 300 500 -title "Attribute Window" attrWindow;
columnLayout -adj 1 attrColumn;
textScrollList -w 300 -h 500 -ams 1 attrText;
showWindow attrWindow;
string $attrs[] = `textScrollList -q -si mainText`;
string $listAttr[] = `listAttr -k $attrs`;

for($attr in $listAttr){
textScrollList -e -append $attr attrText;
}

}

lightwolf
09 September 2007, 09:44 AM
Well i hope this is what you are looking for!
Wow, thanks. Yeah, that is pretty much it. However, I did opt for using an empty group in the end... but this surely comes handy.

I suppose in the end attrNavigationControlGrp just confused the heck out of me because I thought it would do what I expected.

Cheers,
Mike

CGTalk Moderation
09 September 2007, 09:44 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.


1