PDA

View Full Version : MEL - Maya UI Building


Pages : [1] 2

bentllama
01-20-2003, 05:13 PM
This thread is dedicated to Maya UI Building.

Please post any tips, tricks and advanced or general useful Maya UI Building knowledge in this thread.

Please only post Maya UI Building related examples, as there is already a sticky thread for general MEL posting.

bigfatMELon
01-20-2003, 07:41 PM
And since I'm the magic nose goblin who asked for it, it's only right that I contribute something.

Here are links to two terribly useful UI tutorials at Bryan Ewert's site.

The Scripted Panel Tutorial (http://www.ewertb.com/maya/mel/scriptedPanel/index.html)
The Form Layout Tutorial (http://www.ewertb.com/maya/mel/formLayout/index.html)

-jl

dmcgrath
01-21-2003, 04:26 AM
Okey dokey, since I just finished a MEL class last semester.
the direct UI page:

http://cade.scope.edu/courseware/notes/mel/uidesign.html


The entire MEL based set (FRAMES HTML)

http://cade.scope.edu/courseware/notes/mel/index.html

bigfatMELon
01-26-2003, 12:32 AM
This thread didn't exactly take off like a rocket. Perhaps it needs some feeding. Here is a simple tutorial script that shows how to build and manage a textScrollList from the contents of a string array.


global proc scrollExample (){

if (`window -ex "scrollWin"`) //does the window already exist?
deleteUI "scrollWin"; //if it does, kill it

//define the window
window //create a window
-title "Text Scroll Example" //give it a title
-w 250 -h 220 //set width and height
"scrollWin"; //give the window a unique name
columnLayout -w 250; //create a column

text -l "" -h 10; //text spacer
textScrollList //set up the scroll list
-h 200
-w 240
-ams false //disallow multiple selections
-sc "scrollWinUpdateSel" //the command used when an item is selected
"swScrollList"; //the control is given a unique, explicit name
textField -w 240 "scTextField"; //text field also gets a unique name
text -l "" -h 10; //text spacer

swUpdateWin; //call a general purpose window update

showWindow "scrollWin"; //tell Maya to draw the window
}



//general purpose window updater. This makes it
//easy to refresh the window contents from anywhere
//in the script with a single call
global proc swUpdateWin (){
string $cams[] = `ls -cameras`; //create an array of all the cameras in the scene
string $x; //it's a good idea to declare all variables

textScrollList -e -ra "swScrollList"; //clear the scroll list before adding new stuff

//the list is now empty
for ($x in $cams) //loop over the array with $x
textScrollList //fill in the contents of the scroll list
-edit //put the command in edit mode
-append $x //add every $x in $cams to the scrollList
"swScrollList"; //gotta tell it which scroll list to append to
}



//the selector proc. This is called by the command
//attached to the scrollList itself. The -sc flag
global proc scrollWinUpdateSel (){
string $sel[] = `textScrollList //define an array for the selection
-query //put the command in query mode
-selectItem //get the string of the item the user selected
"swScrollList"`; //naming controls makes this a snap

textField //put the name of the selection in the field
-edit //put the command in edit mode
-text $sel[0] //text is what we're editing. $sel is that text
"scTextField"; //name of the text field
}


-jl

dwalden74
01-26-2003, 12:21 PM
Hi Melon-

I also have procedures to add and remove items from a given textScrollList.


//Procedure adds selected objects to a given textScrollList.
global proc dwAddSelectedObjectsToList (string $textScrollListName)
{
//find out what exists in textScrollList.
string $textInScrollList[] = `textScrollList -q -ai $textScrollListName`;

//find out what´s selected in scene.
string $currentMayaSelection[] = `ls -sl`;

if (size($currentMayaSelection) == 0)
error "Nothing selected.";

//remove all items from textList (need to "refresh" list).
textScrollList -e -removeAll $textScrollListName;

string $allSelectedArray[] = `stringArrayCatenate $textInScrollList $currentMayaSelection`;

string $cleanedSelection[] = `stringArrayRemoveDuplicates $allSelectedArray`;


for ($current in $cleanedSelection)
{
textScrollList -e -append $current $textScrollListName;
}
}



..and to remove selected items from list:

//Procedure to remove selected elements from a textScrollList.
global proc dwRemoveObjectsFromList (string $textScrollListName)
{
string $currentTextSelection[] = `textScrollList -q -si $textScrollListName`;
if (size($currentTextSelection) == 0)
error "Nothing selected in text list.";
for ($currentText in $currentTextSelection)
{
textScrollList -e -ri $currentText $textScrollListName;
}
}


:beer:
David

alexx
02-03-2003, 08:21 PM
not that i want to say this thread is not worthy to be alive (it definitely is, since UI building took me the longest time to learn).. but dont you think that it would be well placed in the other mel scripts sticky thread?
the more sticky threads there are the faster questions plunge to page 2 that most ppl dont read.

how bout it?

cheers

alexx

dwalden74
02-04-2003, 10:36 AM
Yeah, good point. I also noticed the plethora of sticky threads was kind of overcrowding the normal threads. And yes, I admit it, I never read the second page.... :p
I don't know....maybe there should be a "sticky section" or something where all the sticky threads go...

UI building took me the longest time to learn

longer than particle scripting??? I can't believe that!


:beer:
David

bentllama
02-04-2003, 05:46 PM
they are sticky threads for a reason. so you can easily find what you are looking for. myself as well as a few others dont feel it its getting over crowded. as far as posts in this thread and the sticky... any posts with just thanks! great! or other banter that does not contribute actual MEL or MEL links and info will be culled... to effectively organize them into a streamlined resource...

there are some stickies that can be "unstuck" and we will do a better job ensuring that page 1 does not get overcrowded...

if you feel a thread is worthy of page 1 glory, do us all a favour and *bump* it up... :)

I appreciate your guys' comments on the validity of this thread and stickies in general... thanks.


:beer:

twidup
03-20-2003, 11:12 AM
I hope its ok to ask UI related questions here, if not, feel free to move this over to the mel forum.
I have used the -w/-h flags on controls before without a problem, and also the position controls for formlayout, but here is the question. Whenever I have tried to use -w/-h for a window, they dont seem to work beyond the first time the window is opened. Is there a secret trick to this or something?

ie: I create a window with no retain flag and -w/-h set. test it, it works but I add a new control to the script, so I close that window, source the script again and it should be a bigger window, but its the same as the previous one, even though the width/height has been changed.

Thanks
-Todd

dwalden74
03-20-2003, 01:42 PM
Yeah, this stuff with the dimensions of windows/controls has always been a mystery to me as well. Even when you specify explicit w/h it just kinda´does what it wants. The only real way to fix the size of a window in my experience is to use -sizeable 0, but that of course fixes it at the specified size. There´s probably a logic somewhere to this but I stopped searching for it, and it´s not such a big deal for me....

:beer:
David

alexx
03-20-2003, 02:02 PM
there is a logic indeed :)

usually in your preferences you have a checkbox set (default), that is called:

interface-> Windows: remember size and position

with that one switched on, you can only one specify the width and height of your window. after that maya reads the size out of the following file:

"C:\Dokumente und Einstellungen\yourname\Eigene Dateien\maya\4.0\prefs\windowPrefs.mel"

you can edit that file and throw out the line which has the size for your window.. then you can create it again with your own settings.

cheers

alexx

dwalden74
03-20-2003, 02:30 PM
Alexx you is the man!

:beer:
David

alexx
03-20-2003, 07:47 PM
you´d better *not* ask me how long it took me to find THAT out ;)

cheers david :beer:

alexx

twidup
03-20-2003, 08:42 PM
yeah, thanks a lot alexx.

bentllama
03-24-2003, 07:25 AM
Originally posted by dwalden74
Yeah, this stuff with the dimensions of windows/controls has always been a mystery to me as well. Even when you specify explicit w/h it just kinda´does what it wants. The only real way to fix the size of a window in my experience is to use -sizeable 0, but that of course fixes it at the specified size. There´s probably a logic somewhere to this but I stopped searching for it, and it´s not such a big deal for me....

:beer:
David

can't you just use the command

windowPref -remove myWindowName;

to get rid of your size and position prefs for that window???

bentllama
03-24-2003, 07:53 AM
Originally posted by dmcgrath
Okey dokey, since I just finished a MEL class last semester.
the direct UI page:

http://cade.scope.edu/courseware/notes/mel/uidesign.html


The entire MEL based set (FRAMES HTML)

http://cade.scope.edu/courseware/notes/mel/index.html

do you know of any mirror sites for these? they seem to be offline.

CaptainSam
03-31-2003, 04:40 PM
You can override the window size set by the user prefs by using the edit flah.

window -w 100-h 100 myWindow;
columnLayout;
button;
showWindow myWindow;

resize the window manually, then run

window -e -w 100-h 100 myWindow;

Just add that line after the showWindow command, and the window will open the same size

dmcgrath
04-07-2003, 08:34 AM
Originally posted by bentllama
do you know of any mirror sites for these? they seem to be offline.

Check them every once in a while. They come and go.

nottoshabi
08-02-2003, 09:26 PM
Hey guys I need to build this UI. And I'm a little stuck. :annoyed:
I need some help please.

The UI should look look this:

It needs 2 tabs:
The first tab needs to have 2 buttons with a sliders next to them on the same line.
And the second tab 4 buttons with silders next to them.

twidup
08-11-2003, 10:18 AM
hey guys, I have another question...yeah, i am full of them.

I am working on a UI for several scripts, and I was using a scrollLayout as a child of a tabLayout.

Everything is not OK immediately.

string $testTab =`scrollLayout
-horizontalScrollBarThickness 0
-verticalScrollBarThickness 16`;
columnLayout -h 300 -columnAttach "both" 5
-rowSpacing 10 -adj true;

button;
setParent ..; setParent ..;

ok, here is the BAD part.
When I use this, the columnLayout is only a few pixels tall because the scrollLayout shrinks up on it. any suggestions?

Thanks in advance

-Todd

h0tice
08-14-2003, 05:00 AM
try this

window -t "Tab Window" -w 240 -h 430 ;


string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5 -scr 1 -hst 16 -vst 16 -cr 1`;


string $tab1 = `columnLayout -adj 1`;
setParent..; setParent..;
string $tab2 = `columnLayout -adj 1`;
setParent..; setParent..;

tabLayout -edit
-tabLabel $tab1 "Animation"
-tabLabel $tab2 "Rendering"
$tabs;

showWindow;

i used this layout to put all scripts that i have collected (from highend and simplymaya, and some scripts of jason.) into one window.

note that the -scr flag makes your tab layout sctollable.

and here's the zip file of the ui that i did.

hope this helps.


:thumbsup:

twidup
08-15-2003, 02:02 PM
h0Tice, worked great, thanks for that one

h0tice
08-17-2003, 09:31 AM
no prob bro

:D :beer:

dwalden74
09-15-2003, 03:29 PM
I want to place a "helpLine" at the bottom of a UI. This UI consists of one main tabLayout, and each tab is itself a separate formLayout. So every time you select a different tab, a different formLayout is shown. Problem: I noticed that UI´s do not support multiple helpLine controls (at least that´s what it seems like). I tried to put a separate helpLine at the bottom of each formLayout (in this case I tried it on 2 different form layouts), however the first helpLine in the first formLayout was no longer responsive- only the second helpLine (the last one I created) worked.

Question: is there a way to place the same helpLine control under multiple form layouts? In this case, the same control would have multiple parents. I´ve actually tried placing the helpLine with the same control name under different fom layouts, but still only the last helpLine was responsive. I would also like to avoid rebuilding the entire UI when I select a tab.

:beer:
David

CaptainSam
09-16-2003, 01:02 AM
why dont you do something like this (pseudo code)

window
$main= formLayout
tabLayout
tab 1
tab 2
tab 3
setParent $main

helpLine
showWIndow


Then attach the helpLine to the bottom and the bottom of the tabLayout to the helpLine, or something like that

dwalden74
09-16-2003, 09:01 AM
Yeah, that´s my alternative. But I wanted to avoid this just because the way the UI is built it seems more intuitive if the helpLine is inside the tabLayout, not out.

-david

brubin
11-11-2003, 02:52 PM
Originally posted by dwalden74
Yeah, this stuff with the dimensions of windows/controls has always been a mystery to me as well. Even when you specify explicit w/h it just kinda´does what it wants. The only real way to fix the size of a window in my experience is to use -sizeable 0, but that of course fixes it at the specified size. There´s probably a logic somewhere to this but I stopped searching for it, ...

... but for those who still care: the usage of setting optionVars for frequently used productionscripts is not as widely popular as the power of the command would deserve! and besides - setting up and drawing information from (just like e.g. windowSize and -Position) an optionVar is a) personal and b) not the least as complicated as understanding formLayout! ;)

my2P'sworth...
s.

sonicstrawbery
02-28-2004, 05:29 PM
I'm looking for something about UI building in maya.

I'd like to know if it's possible to make a realtime camera view or a render view inside a layout that is in a window .

If yes, could someone explain me what type of command and flags should i use to do that ?

thanks

Levitateme
03-30-2004, 08:14 PM
yah cipher, that would be great just like how xsi has the draw render region? if you get that accomplished please let everyone know.

takashiuan
05-22-2004, 01:55 PM
Hello every1, I am quite new to Maya and MEL, and I was looking for some information:

What is the Name of the Script Editor Window in MEL?

I found out about:

- Outliner : outlinerPanel1Window
- Hypershader: hyperShadePanel1Window
- Attributes: AEWindow

But for the Script Editor Window my method didnt work! (Turn on 'Echo All Commands' in the Script Editor window and read what it does...)

So, hopefully some pros out here can help me out:-)
greetz

h0tice
05-22-2004, 02:23 PM
ScriptEditor;

takashiuan
05-24-2004, 08:54 AM
As far as I understand the matter till now, ScriptEditor; is a script that does this:

showWindow $gCommandWindow;

Now I would like to write a Script to close the ScriptEditor. How can I deal with this in MEL? Any suggestions?

vinceton
06-08-2004, 05:33 PM
You cannot use "deleteUI $gCommandWindow" for that particular case. But you can use this:
window -edit -vis 0 $gCommandWindow;

minyusf
06-09-2004, 07:20 AM
Originally posted by takashiuan
As far as I understand the matter till now, ScriptEditor; is a script that does this:

showWindow $gCommandWindow;

Now I would like to write a Script to close the ScriptEditor. How can I deal with this in MEL? Any suggestions?


try this.....



//toggle the script editor

{

string $scriptWin = $gCommandWindow;

int $scriptTog = `window -q -vis $gCommandWindow`;

if ($scriptTog == 1)

window -edit -vis 0 $scriptWin;
else

showWindow $gCommandWindow;

};


//get the last panel that had focus

string $returnPanel = `getPanel -wf`;
setFocus $returnPanel;

Macj
06-12-2004, 08:20 PM
Hey guys,

I am attempting, with much frustration, to just put an image as the background of a UI window for the purpose of creating a custom character rigging tool. I am using OSX and as far as I know you can use .bmp, .xpm or .iff for the image. When I use the command image -i path file name , the window comes up, but doesn't display the image or an error. This is what I have thus far:

window -ra;
window -widthHeight 450 530 -title "Goblin Control" gobWin;
formLayout;

image -vis 1 -image "/Volumes/Storage/Projects/MEL_CharacterUI/GoboUI_background.xpm";

showWindow;

jedijrmax
06-17-2004, 05:57 PM
Hey everyone,

I just have a question that nobody seems to know how to answer, so maybe you could help...

I am building a Maya UI, and I need to include a timeline for the user to scroll through... ok no problem...

BUT, it also needs to be able to show the keys...of selected objects and I CAN NOT for the LIFE of me, figure out how to get this to work

I used modelPanel and a timePort widget. I've tried using the timeControl function to edit the timePort in my UI and i get an error saying that a time Control already exists.


Any help will be great!.. thanks if nobody knows, maybe you could refer me to a ... book, online source, or person that is knowledgable enough to help me? This is so important that I get this working and I've been pulling my hair out for over a week now.

Salaadin
06-20-2004, 03:27 PM
hi guys,, im trying to use the MJ Poly Tools in maya 6 but the script doesnt run..do you know if it doesnt support maya 6 ?? but at the same time it works on maya 5 even though it says its for maya 4 ???

thanks

zeroeefx
07-29-2004, 10:26 AM
[QUOTE=jedijrmax]Hey everyone,


I am building a Maya UI, and I need to include a timeline for the user to scroll through... ok no problem...

BUT, it also needs to be able to show the keys...of selected objects and I CAN NOT for the LIFE of me, figure out how to get this to work

QUOTE]

Here is how i get it to work with a row layout.. basic

rowLayout -nc 3 -ad3 3 -cw3 118 115 791 -cat 3 "left" 10;
symbolButton -i "C:\\images\\kbnimages\\knkey.bmp"
-c " setKeyframe (up to ?)"; // you set it up
symbolCheckBox
-ofi "C:\\images\\kbnimages\\knkey.bmp" // i made my own images
-oni "C:\\images\\kbnimages\\knkey.bmp" // i made my own images
-onCommand " setKeyframe (up to ?)";
symbolCheckBox
-ofi "C:\\images\\kbnimages\\knplay.bmp" // i made my own images
-oni "C:\\images\\kbnimages\\knstop.bmp" // i made my own images

-onCommand "play -forward true" -offCommand "play -state off";
timePort;
setParent..;


But you can use maya images if you like, but when i'm making a gui. I like to have 13 pieces of flare.........

GennadiyKorol
09-04-2004, 04:17 PM
Here's some kind of problem I've beed fighting for a while.
For example I want to add some menu items to one of maya's menus( Polygons for instance).
I can use the set parent command or -p flag to parent my item to needed menu. I't seem's to work ok while I'm adding the item after maya have already started, but once I add it to user setup to add the menu item every time maya starts it kills the whole menu, leaving only my item, which I intended to add.
Is there something I'm missing?

Iconoklast
09-11-2004, 09:12 PM
Mr Hawk, the best way to go about adding menu items to maya's current menu lists, is to copy the menu list from the Alias/maya6.0/scripts/startup (or /others) directory, and copy them into your local scripts directory, and just modify the contents.

Buexe
09-11-2004, 09:26 PM
"but once I add it to user setup to add the menu item every time maya starts it kills the whole menu, leaving only my item, which I intended to add.
Is there something I'm missing?"
Are you using the -edit flag, if not that could be a reason the menu gets replaced.
just a thought
b

zeroeefx
09-11-2004, 11:14 PM
here is one i have done hope it helps..
http://www.kennorman.com/assets/images/mel/kntools/KNtools.jpg

--Ken

asod
09-30-2004, 02:52 PM
I''ve custom UI and I want to dock into Maya main panle.
I'm getting hard time from panle commands related to my request
if you figured it out... spread the word

zeroeefx
09-30-2004, 08:44 PM
look up one sorry my link was crap....

mclavan
11-16-2004, 08:42 AM
I've put together a mel script that works as an editor for user interfaces. It has over 32 controls in it and 8 layouts as well. I wasn't sure if this would be the best place to post this but I've found this script really sped up manufacturing UI. I'd love to get some feed back on this script and see how you guys like it.

http://www.3dsetup.com/scripts/guiBuilder.mel

Yours truly,
Michael Clavan
www.3dsetup.com
mc@3dsetup.com

davestewart
11-17-2004, 08:45 PM
Hello all,
I'd like to know if it's possible to embed a Microsoft ActiveX control (TreeView, ListView) in a custom interface, then access it using it's methods and properties.
Thanks,
Dave

mitralone
12-02-2004, 03:21 PM
Hi there,


I am trying to make a toy for myself with Mel. Actually I am a transfer from MAX and I want to create a UI where I input the x y z coordinates and use these numbers to move scale or rotate the selected object.

I am having a lot of difficulties, especially with the form(text box and controls on the form) but I need to know how to take the values from the textboxes and use them with the move command. I did this and it is giving a Invalid Argument error.

I have 3 textFieldGrps representing x y and z coordinates. I take the coordinates and put them in a string I call komut. I just want to use this komut's content with the move tool. When I type the command manually (like move -rpr 10 15 25 in script editor), it works but this way it does not). Please help ,me where I am doing wrong and also can you point me to a good UI tutorial. I want to create a interface like the Duplicate window but only for coordinates.

Thanks for the help and here is what I did so far.



global proc Tufan()
{
//check& destroy
if((`window -exists koordinat`) == true) deleteUI koordinat;

//create

window -title "Coordinate Entry" -wh 150 60 koordinat;

//controls

columnLayout;
textFieldGrp -label "X" -text "0" xcor;
textFieldGrp -label "Y" -text "0" ycor;
textFieldGrp -label "Z" -text "0" zcor;
button -l "Move Absolute" -c "tam";
button -l "Move Relative" -c "rel";

//show it
showWindow koordinat;
}

//call it
Tufan;
global proc tam()
{
string $komut= `textFieldGrp -q -text xcor`;
$komut=$komut + " ";
$komut=$komut + `textFieldGrp -q -text ycor`;
$komut=$komut + " ";
$komut=$komut + `textFieldGrp -q -text zcor`;
$komut=$komut + " ";
move -xyz $komut;

}
global proc rel()
{
string $komut= `textFieldGrp -q -text xcor`;
$komut=$komut + " ";
$komut=$komut + `textFieldGrp -q -text ycor`;
$komut=$komut + " ";
$komut=$komut + `textFieldGrp -q -text zcor`;
$komut=$komut + " ";
move -r $komut;
};

mitralone
12-02-2004, 03:37 PM
hey there,

I found it out. Eval a string and it solved. Now I need to learn how to make a good UI. Waiting for the UI tutorial links. Thanks all.

dmac
12-15-2004, 08:25 PM
Hey

I hope someone can help me out a tad I have managed to make a simple UI

To help in rigging a player model I have it all dun BUT! can’t seem to get a function working

I need to scale the bones/rig from a reference node …. Trying to have these controls in my UI

I know am doing something wrong can someone point it out please and thanks



floatSliderGrp -l "scale reference " -field 1;

connectControl $field ( $reference + ".scale");

connectControl $SliderGrp ( $reference + ".scale");

Mikademius
02-17-2005, 04:42 PM
I'm surprised people actually plan on changing userPrefs.mel....
You should always remember that if other people want to use your script, make it as easy for them to use as possible. To force something like that is not good.... Here's a copy from an article I'm currently writing that involves some heavy UI scripting.

Copied form :
www.final3.com (http://www.final3.com)

The article is not done so this is exclusive :)

---------------------------------------------------------------
windowPref -enableAll true; and windowPref -enableAll false;
---------------------------------------------------------------

"true" is of course when it's turned on and "false" turns it off. This is a boolean value.0 = false (off), 1 = true (on) Just like visibility is a boolean value. A boolean value
can only have one out of two options. "On" and "Off"/ "0" and "1".
We can use this to check if the user has this option turned on or off because we want the AUGBuiler UI to be the correct size no matter what. We check this using an if-
command. This is what we tell the script to do:

If the user has "Remember size and position" turned on, turn it off, open window and then turn it back on. I don't want to create a script that changes userprefs without
doing one of the following. Create an ERROR message or pretend it was never changed by changing it back.

-------------------------------------------------------------------------------------------
windowPref -enableAll false;
error "your userpref has been changed (remember size and position is now turned off)";
-------------------------------------------------------------------------------------------

This turns the "remember size and position" off and tells the user that the script has changed the setting. I do not reccomend to do it this way, I just wanted to show you
the ERROR command you should use if you change ANYTHIG out of the users control. I will stick to the if command. This script "translates" the if sentance I wrote earlier.

--------------------------------------------------------------
string $getWindowPreferences = `windowPref -q -enableAll`;

if ($getWindowPreferences == 1)
{
windowPref -enableAll false;
AUGWindow;
windowPref -enableAll true;
}

else
{
AUGWindow;
}
-------------------------------------------------------------

I created a string that gives us the boolean value for the windowPref command. Look up "string" in the help-file if you're unfamiliar with the usage of it.
Strings are sequences of characters. It can be anything you want to name it. If you take a closer look at the string line you can see the "-q" flag. What this flag does is
setting the string in query mode. We need it to be in query mode because we want to get a value for later use. Look up int, float boolean too. These are variables with
certain limits unlike "string"

You can use a print-command to see if what you are doing is totally wrong or undoubtfully correct.

-------------------------------------------------------------
string $getWindowPreferences = `windowPref -q -enableAll`;
print $getWindowPreferences;
-------------------------------------------------------------

If you look in the script editor echo-window you'll see a "1" or a "0" depending if you turned the setting on or off.

if ($getWindowPreferences == 1) We tell the script to check if the string "getWindowPreferences" returns a value of one and one only. If it appears to be the case. The script
will execute the command between the brackets.

windowPref -enableAll false; We turn the "remember size and position" off
AUGWindow; We open the Window
windowPref -enableAll true; And then we turn "remember size and position" back on


I am creating a rifle and I want to create a UI that can build the rifle depending on the parts I select.... Hope you found some of this useful. NEVER EVER change a users prefs without telling him, the conseuences can be catastrophic!!!

eblondin
03-09-2005, 07:42 AM
alrighty I know how to do this with the script editor but I cant find the name of the windows for any other window in maya to toggle their window visibility or close/open them.

mel script to toggle the script editor is

{

string $scriptWin = $gCommandWindow;

int $scriptTog = `window -q -vis $gCommandWindow`;

if ($scriptTog == 1)

window -edit -vis 0 $scriptWin;
else

showWindow $gCommandWindow;

};


but I want to be able to do this with any window, specifically, component editor, hyper graph, hyper shade, outliner, graph editor, but I cant seem to find what maya calls these windows to set up a command that closes them. if anyone can help that would be supper sweet.


i have hot keys to open all of these windows but the same command that i use to open the spefefic window gives me an error saying that maya cant find the object example


// Error: line 1: Object not found: HypergraphWindow //



help! :)

Mikademius
03-09-2005, 09:53 AM
This is a good example of a case you would want to find out by opening the windows in maya to read what maya does. Just turn on the "execute all commands" command and read while doing.

hypershade = HypershadeWindow;
hypergraph = HypergraphWindow;

etc. etc.

Nicool
03-09-2005, 10:37 AM
I've finally coded a UI builder. Works from function declaration automatically. http://ndhaussy.free.fr/melScript

If you have any feedback ;)

Mikademius
03-09-2005, 12:24 PM
I've finally coded a UI builder. Works from function declaration automatically. http://ndhaussy.free.fr/melScript

If you have any feedback ;)

I would love to check it out. I don't have time here at work right now, but I read some of your scripts and they look cool. I'll try some of them out at home later....
:thumbsup:

StuartVarrall
03-16-2005, 04:36 PM
Hey, I've been having a play around with melUI, trying to find out if it's possible to have 2 buttons in a rowLayout that both resize horizonally when the window is resized?

I've got it working so that the button on the right correctly resizes, but can't see a way of getting them both to do it together.


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

window -title "windowX" -widthHeight 120 100 -s 1 -tlb 1 windowX;

columnLayout -columnAttach "both" 0 -rowSpacing 2 -columnWidth 100 -adj 1;

separator;
text -height 13 -label "Buttons";
separator;

rowLayout -numberOfColumns 2 -columnWidth2 60 60 -adjustableColumn 2 -columnAttach2 "both" "both" -columnAlign2 "center" "center";
button -label "but01" -height 20;
button -label "but02" -height 20;
setParent ..;
showWindow;


Thanks,

Stu

Nicodemia
04-03-2005, 02:33 PM
Hey everyone
Ive jus purchased maya and am transfering from cinema4d.
Ive got a dual monitor setup on a dual 1.25 ghz G4.

I dont know how to rearrange my maya UI though to make use of the space.

I have no MEL experience and wondered if there are any pre-made UIs that can be downloaded?
Please point me in the right direction.
Thankyou in advance

Nico

Nicodemia
04-03-2005, 02:49 PM
Hey everyone
Ive jus purchased maya and am transfering from cinema4d.
Ive got a dual monitor setup on a dual 1.25 ghz G4.

I dont know how to rearrange my maya UI though to make use of the space.

I have no MEL experience and wondered if there are any pre-made UIs that can be downloaded?
Please point me in the right direction.
Thankyou in advance

Nico

Iconoklast
04-03-2005, 03:20 PM
I haven't seen any other downloadable UI's :( But what kinda UI rearranging have you got in mind?

Nicodemia
04-03-2005, 03:25 PM
In Cinema 4d I had most of my tools and a perspective view on one screen and my orthographic views and main tools on the other. I cant work out how to do this in maya.
Can You help?

Iconoklast
04-03-2005, 03:31 PM
Sorry mate, I wouldn't have a clue how with dual monitors. Try a search, I've seen something like this mentioned before here.. Not going to guarantee that though :P

Nicodemia
04-03-2005, 03:39 PM
I've tried a search but i had no luck.
Thanks anyway Iconoklast.
Anyone else know a way to do this?

nottoshabi
04-04-2005, 12:30 AM
I know in Maya you can tear off screans. Do a search on this site for dual monitors or tear off screans. I saw a thread couple of days ago and these 2 guys were discussing how great that was to be able to tear off screans and work in dual monitors.


Good luck:bounce:

ietra
04-04-2005, 01:13 AM
In Cinema 4d I had most of my tools and a perspective view on one screen and my orthographic views and main tools on the other. I cant work out how to do this in maya.
Can You help?

Don't know of any scripts, but it's pretty easy to set up, depending on your video card. I only know NVidias, but with that you can set up horizontal span across the two monitors, and specify that apps can span the monitors but child windows can't. Then you maximize the main Maya UI on one monitor, and put things like hypershade, graph editor, whatever on the other. In maya prefs you can tell it to memorize window locations on exit.

You can also tear off panels (under Panel menu) and put them wherever you like. No scripting required, unless you really want to.

Nicodemia
04-04-2005, 01:22 AM
thanks for the help guys

Ive worked out how to tear off panels and rearrange them on my second screen.

How do i now save this ui layout so maya starts up with it?

Thanks again for your help so far

Mikademius
04-04-2005, 08:30 AM
If you open your script editor and view by script node name you can add a node with the mel for all your windows. Remember to check "Execute on" startup. This won't make sure you have your layout every time you open maya though. Only on that specific file. Even though, you can create a shelfbutton for it if you are patient enough to go click an extra icon after startup :)

SajNT
05-10-2005, 10:52 AM
Not sure how much will it help, but i've had the hassle of toggling on and off, the weights in the component editor while assigning weights to each individual verts. What this script does is, it creates another window that lists out all the joints that's binded onto the mesh. From there you can select, hold all, or unhold all joints, as well as individual ones when u wanna take weights off or onto the verts...

SajNT
05-10-2005, 10:53 AM
Sorry here's the attachment..:)

cameronfielding
05-18-2005, 03:11 PM
just a few tips really that i found ultra useful:

if youre planning on dynamically updating UI elements or building any kind of semi-complex UI -- make sure you understand the basic 'parenting' structure ... that way your script will 'know where it is' within the interface.

formLayout is the king. Get your head around this, and you can create massivley detailed and intricate UIs. Its not at all as complicated as it first appears if you give it a go.

you can place layouts within UIs using formLayout. So instead of creating every button and checkbox with formLayout - create them in simpler row or columnLayouts, then place the actual layout exactly where you want it.

dont clutter Layouts with buttons etc that dont need to be there. Use the MenuBar to add extra options or functions into a concealed menu bar at the top of the window.

Use menu and MenuItem to create 'right-click options' over whatever control or UI element you like ( this is very powerful )


i can post examples of any of these if anyones interested.

W. A. Studios
05-23-2005, 08:24 PM
Hey Everyone...

I've got this great plug-in that I've finished writing and now I need to figure out hwo to write the paths so that people can download my plug-in and to the /scripts directory and the icons to the /prefs/icons directory without error messages. Anyone know how to write the paths to do that? I can of course write explicit paths but those would be specific to my computer and directory structure. I was thinking it might be something more like this:
symbolButton -image "/../prefs/icons/icon.jpg" -c "" button1;

I am also having a Very hard time getting Macintosh to read image files for the symbolButton that the PC can easily read.

Any help or comments on this would be GREATLY appreciated.
Thank You.

sunit
05-23-2005, 10:14 PM
"internalVar" will give you a couple of directory paths (scripts, application, workspace, temp)

i'm assuming you want the installer to copy the scripts and icons directly to the appropriate directories.

-sunit

W. A. Studios
05-23-2005, 11:42 PM
I'm expecting the user to place the plug-in files in teh appropriate directories. However, I need to write my script so that the UI calls for files from the proper location. If I make explicit directory declarations then this UI won't work for anyone's computer but mine and users will be forced to open up each script and change all the paths to their local dir structure. I obviously can't have this. So I'm looking for how to use paths with abbreviations (/../prefs/icons) instead of (C:/my computer/documents and settings/joeblow/my documents/maya/6.0/prefs/icons). :cry:

Also... anyone know how I can get .bmp or .jpg to show up in the symbolButton command on an Apple? I can get it to work on a PC fine. :argh:

I wish Maya help gave more Macintosh help. :banghead:

sunit
05-24-2005, 12:01 AM
this seems like the right command for you ("internalVar")

it'll return the user's profile directory - so in your plugin or script, you'd declare a string with this directory, and then append the script, or icon, or whatever to the end.

such as:

print `internalVar -usd`;

or

{
string $usd = `internalVar -usd`;
print ($usd + "joeblow.mel");
}

will print out your local profile directory where maya puts its preferences. unless i'm misunderstanding what you're looking for...

-sunit

W. A. Studios
05-25-2005, 05:57 AM
Thank You so MUCH for that!

I've used the following line of code: string $userPath = (`internalVar -upd` + "icons/");

and then later I use the following when creating a button:
[i] symbolButton -i ($userPath + "iconName.bmp") -c "" buttonName;

:thumbsup: :cool: :applause:

Mikademius
07-07-2005, 11:17 PM
internalVar -usd will take you directly to the icons folder...

EigenPuff
07-11-2005, 09:54 PM
I have a problem similar to what Twidup posted on this forum 'bout two years ago (8-11-03), but the solution for his problem doesn't work for me.

I have been charged with updating a script written quite a while ago that would look in specified directories and add all of the Maya Files it found to a grid layout as sort of a shortcut bar. I wish to wrap the gridLayout in a scrollLayout like such:

window -t "Anim Palette" -tlb true -rtf true -w 345 -h 360 animPalette;
columnLayout -columnAttach "both" 5 -columnWidth 335 -adj true jm2al;
// ... other controls ...
scrollLayout -cr true;
gridLayout -numberOfColumns 4 -autoGrow true
-columnsResizable true -cellWidthHeight 100 25
-nr 25 animButtonLayout;
setParent..;

... but I am running into a problem where the vertical scroll area is only size of a button and a half. I have dug through the documentation "magic flags" but haven't found a cure. Any one of you kind souls have a clue to share?

Thanks

Mikademius
07-12-2005, 12:42 AM
Like this??




if(`window -ex $mainWinWindow`)
deleteUI $mainWinWindow;


string $mainWinWindow = `window -t "Anim Palette" -w 250 -h 200 animP`;
string $mainColumn = `columnLayout mainColumnLayout`;
// ... other controls ...
string $mainScrollLayout = `scrollLayout -cr true -h 200 scroll`;
string $newFrame = `frameLayout animPalette`;
string $mainGridLayout = `gridLayout

-nc 3
-cr 0
-cwh 100 25
theGrid`;
button; button; button; button;
button; button; button; button;
button; button; button; button;
button; button; button; button;
button; button; button; button;
button; button; button; button;
button; button; button; button;
button; button; button; button;



showWindow $mainWinWindow;


Nested in a frameLayout.. I'm not sure if I understood your question though :curious:

EigenPuff
07-12-2005, 06:17 PM
Awesome! That helps out a lot. The vertical sizing looks funky, but I'll play with it a bit to get what I want.

Thanks

Mikademius
07-12-2005, 09:25 PM
I hope you can get it to work somehow. If not, post what you get and then we can look into it together ;)

Infinity Rogue
07-13-2005, 06:47 PM
Hi, I have run into the same problem as an other user here on CG Talk. I, too, have a UI with a timePort, and I cannot get that timePort to show keys on it. Another user was kind to post his version of how it would work, and i have tried to put that into the creation of my window, but it still doesnt work. Can any one see what i am missing to get those keys to show? Thanks


window -title "LipSynch" -sizeable false -minimizeButton false -maximizeButton false -width 800 -height 500 LipSynch;
paneLayout -configuration "vertical2";
paneLayout -configuration "horizontal3" -paneSize 1 50 80 -paneSize 2 50 10 -paneSize 3 50 10;

modelPanel -camera "LipCam";

setParent ..;

rowLayout -numberOfColumns 3 -columnWidth3 100 100 100 -rat 3 "both" 10;


symbolCheckBox
-ofi "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERTIMEPLAY.BMP"
-oni "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERTIMESTOP.BMP"
-onCommand "play -forward true"
-offCommand "play -state off";

symbolCheckBox
-ofi "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERTIMEPLAY.BMP"
-oni "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERTIMESTOP.BMP"
-onCommand "play -forward true"
-offCommand "play -state off";

symbolButton -i "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERMENUICONKEYS.BMP" -c "setKeyframe";

/*symbolCheckBox
-ofi "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERMENUICONKEYS.BMP"
-oni "C:\\Program Files\\Alias\\Maya6.0\\extras\\icons\\USERMENUICONKEYS.BMP"
-onCommand "setKeyframe";*/

//setParent ..;

setParent ..;

timePort;

setParent ..;

outlinerPanel;

showWindow;

Mikademius
07-14-2005, 08:44 AM
I'll have a look at work.
btw: I STRONGLY recomend you use internalVar instead of whole paths....

edit:

I was thinking maybe "timeControl" could have a sollution here, but I can't get it to work right away.... You can only create ONE timeControl, but if I go:
string $myTimeCtrl = `timeControl myTC`;

it will try to create one every time... I'll try to fix that with an !-ex or -ex.
Anyhow I also found out that it wont display keys unless your selection is in "mainListConnection"... ( Specifies the name of a selectionConnection object which the time slider will use as its source of content. The time slider will only display keys for items contained in the selectionConnection object. )

Also by checking out "selectionConnection" there are ways to get your objects into that selection for later use as a source...

As you can see I haven't totally figured it out, but I'm trying to. Just hang on and maybe we can fix it together :)

Infinity Rogue
07-15-2005, 12:54 PM
thank you, I truly appreciate that.

Mikademius
07-15-2005, 03:00 PM
thank you, I truly appreciate that.

np. MEL is to funny to be untouched :)
however I have not yet found the sollution to your problem. I was thinking that maybe I could just set `ls -sl` as a selectionConnection. You only need to see the keys for the obj. selected anyway. I'll see if I can manage to take a look at it this weekend. It's my summerholiday, but with rain outsise I might do something usefull...

Mikademius
07-20-2005, 02:20 PM
Can you please post the entire script you got the info from so I can see what he did?

Carina
07-24-2005, 01:07 PM
I've been fiddling about with basic UI stuff before, i.e. using standard text, sliders, buttons etc..

I'm playing about a bit writing a plug-in and would like to have a control in my ui that displays a straight "spline" and allows the user to pull different sections of it to alter the shape. The shape would then be passed on to be used in the plug-in..

I'm finding it difficult to get my head around the UI components available.. The only ready made control I can find that looks sort of similar is the gradientControl, but it doesn't quite seem the right thing to use..

Any tips?

MunCHeR
07-24-2005, 04:33 PM
Carina, are you talking about something similar to the fluid opacity widget tab in the attribute editor(think thats what its called)?

MunCH

Carina
07-24-2005, 04:36 PM
Carina, are you talking about something similar to the fluid colour widget tab in the attribute editor(think thats what its called)?

MunCH

Which one d'you mean? (screenshot?)

I mean sort of like the graph editor, where you can manipulate the curve in two dimensions..

MunCHeR
07-24-2005, 04:45 PM
Um sorry I dont have unlimited, I remember them mentioning it in the fluids teaser ages ago, found a screen shot for you:

http://zgrachan.com/images/1_4.gif

MunCH

Iconoklast
07-24-2005, 05:04 PM
or the taper curve thing in the AE for a polyExtrude along a curve, or the falloff curve thing for the soft modification tool!

Carina
07-24-2005, 05:05 PM
yeah that's sort of what I mean. I think that's the gradientControl though, which sort of works (ish) but there're no way to manipulate how "soft" the curve should be at each point, i.e. like in the graph editor when you have handles to manipulate each control point
http://lq.amsterdamned.org/images/graph.jpg

Maybe I can just ainclude this with the animCurveEditor command..

LehaS
07-26-2005, 09:20 AM
:wavey: to everyone

This is one my 1st attempts to write my UI window...I m going to create the window which will act as a collection of important attributes which i often use....in this example i just want to track FG status with checkbox command....

I cant get to work following things:
1. How to catch the present state of FG and automatically update the checkbox without storing the value in the variable? Is it possible ?
2. How to "toggle" the FG status when the box is being "toggled"? Right now i found only 3 usefull flags in checkbox command: -onCommand, -offCommand and
-changeCommand...Looks like the last one is going to do the trick but this brings me back again to the 1st question...
3. And the last thing ....is there a standalone command not attribute that "toggles" attributes......i expected to find something like toggleAttr :p ....but no avail...


Here is what i wrote so far....

/////////////////////////////////////////////////////////////////////
global proc info(){
if(`window -exists InfoWindow`)
deleteUI InfoWindow;
window -widthHeight 300 300 -title "Info" InfoWindow;
columnLayout -co "left" 5 ColumnLayout;
checkBox -label "FinalGather" -onc "setAttr "miDefaultOptions.finalGather" 1;" -ofc "setAttr "miDefaultOptions.finalGather" 0;" FGbox;
showWindow InfoWindow;
}
///////////////////////////////////////////////////////////////////

Thanx in advance....:banghead:

Mikademius
07-26-2005, 01:09 PM
About checking the FGstatus in Maya to get the value in your UI.
I suppose you should do this with a scriptJob.

I created a sollution for you that checks the status when you run the window and sets the checkBox value to it's correct value corresponding to the renderGlobals. So when you open the window the correct value is checked. If that's not a good enough sollution I have to go into scriptJobs to help you further. Or.. you can read about scriptJobs yourself :) best way of learning. Then, come back. To be honest, I have to do some reading on scriptJobs myself ;)

And also, when you click the checkBox it sets the correct value in the renderGlobals of course.

In the future, try to write cleaner scripts. It helps you and everyone else reading them ;)


/////////////////////////////////////////////
//leha_sokol @ CGTalk MEL UI building HELP //
//Subject: CheckBox renderGlobals (FG) //
//By Martin Andersson //
//www.final3.com //
/////////////////////////////////////////////


//creates a name for our Window
string $winName = "FGInfoWin";
//kills it if it exists
if (`window -ex $winName`)
deleteUI $winName;

//the window
string $myWindow = `window -t "my FG Info Window" -wh 241 95 $winName`;
string $myColumnLayout = `columnLayout myColumnLayout`;
string $fgCheckBox = `checkBox -l "FG Status" -cc changeCommand FGstatus`;


//this checks the renderGlobalValue before opening the Window and edits the checkBox
string $checkFG = `getAttr miDefaultOptions.finalGather`;
if ($checkFG == 1)
{
checkBox -e
-v 1
$fgCheckBox;
}
else
{
checkBox -e
-v 0
$fgCheckBox;
}


//Status is checked, now open that window :)
showWindow $myWindow;

//This is the proc the checkBox runs on a changeCommand earlier in the script. Check the
//$fgCheckBox string -cc
proc changeCommand()
{

string $getValue = `checkBox -q -v FGstatus`;
if ($getValue == 1)
{
setAttr "miDefaultOptions.finalGather" 1;
}

else if ($getValue == 0)
{
setAttr "miDefaultOptions.finalGather" 0;
}
}

goleafsgo
07-26-2005, 01:36 PM
1. How to catch the present state of FG and automatically update the checkbox without storing the value in the variable? Is it possible ?
2. How to "toggle" the FG status when the box is being "toggled"? Right now i found only 3 usefull flags in checkbox command: -onCommand, -offCommand and
-changeCommand...Looks like the last one is going to do the trick but this brings me back again to the 1st question...
3. And the last thing ....is there a standalone command not attribute that "toggles" attributes......i expected to find something like toggleAttr :p ....but no avail...


This is all you need...


window;
columnLayout;
attrControlGrp -attribute "miDefaultOptions.finalGather";
showWindow;

LehaS
07-26-2005, 01:54 PM
Thanx a lot to both of you guys...

I ll post my window as soon as finish it

Mikademius
07-26-2005, 03:14 PM
This is all you need...


window;
columnLayout;
attrControlGrp -attribute "miDefaultOptions.finalGather";
showWindow;


Error: line 3: No object matches name: miDefaultOptions.finalGather

:sad:

LehaS
07-26-2005, 03:18 PM
Well it works in my case...

Buexe
07-26-2005, 03:19 PM
MR plugin loaded?

Mikademius
07-26-2005, 03:23 PM
MR plugin loaded?
Sure wasn't. Just fired up maya without thinking. Saved preferences now. I render at work, almost never at home so... . well, it worked now and sure was a lot easier and better than my attempt ;)

Soooo, attrControlGrp huh? Better write that one down ;)

Mikademius
08-09-2005, 09:04 AM
Awesome! That helps out a lot. The vertical sizing looks funky, but I'll play with it a bit to get what I want.

Thanks


Also, did you look into this?
int $top, $left, $value[2];
$value = `scrollLayout -query -scrollAreaValue $yourScrollLayout`;
$top = $value[0];
$left = $value[1];

stallion151
08-26-2005, 12:35 AM
hey everyone,

does anyone know if its possible to change the sort order of a gridLayout?
at the moment my buttons read :

row. Left to Right then down next column,
but i'd like them to go
column. down four then next row. repeat.

edit: does anyone know what gridOrder does. whenever i query that onto an existing window it simply adds gridLayout onto the name ie window1|gridLayout1|gridLayout2|gridLayout3|....

thanks

Mikademius
08-26-2005, 09:35 AM
Does your script heavily rely on it to be a gridLayout? You could get the same effect with columnLayouts in a formLayout couldn't you?

Oh, and btw, here's a hug :)

stallion151
08-28-2005, 11:36 PM
well its actually the uv texture window...i've appended another menu to the end of it. and originally i had it as a column layout but the seperator did not close for it. as a gridLayout it works nicer but looks messier.
the texture window uses grid and form layout alot but the script i added is a uv set display radio button collection thing, and it updates every selection change, and being new to MEL i wasn't sure how form layout would react to this...plus i don't know much about formLayout.

*thanks for the hug*....ahhh

stuh505
09-04-2005, 04:24 PM
I was looking through the binary for syflex, and noticed that their UI code is programmed using mel rather than API code. How can you call mel code (and have it compiled into the plugin) from within an api program?

EigenPuff
09-08-2005, 06:35 PM
Thanks Mikademius - I'll look into it pronto.

I got sort of a hacked version for me to work back in July for the animators down stairs, but it got reported back to me recently that that version doesn't work consistently. For some of them, the window height is five buttons; for others it's like 2.

I'll post a stripped down version of my script in a bit if I can't get it to work

Thanks, again.

EigenPuff
09-08-2005, 08:08 PM
Well, here's what I have for the UI script (including Mikademius' suggestion):



//populates the grid layout with a bunch of buttons determined at runtime
global proc MakeButtons()
{
for ($i=0; $i < 50; $i++)
{
string $itemname = string($i);
button -al left -ann $itemname -p "griddy" -label $itemname;
}
}

global proc ScrollResizeCommand()
{
//for debugging purposes - find the area of the scroll area I am trying to fix
int $value[] = `scrollLayout -query -scrollAreaValue "animscroll"`;
$value[2] = `scrollLayout -q -saw "animscroll"`;
$value[3] = `scrollLayout -q -sah "animscroll"`;

intField -e -v $value[0] scrolll;
intField -e -v $value[1] scrollt;
intField -e -v $value[2] scrollw;
intField -e -v $value[3] scrollh;
}

//makes a window with a grid inside of a tab inside of a column.
global proc MakeAWindow()
{
if (`window -q -ex layoutwin`) deleteUI layoutwin;

window -t "Anim Palette" -mnb on -rtf true layoutwin;
columnLayout -columnAttach "both" 5 -adj true jm2al;
text -l ""; //place holder for other controls

$tabs = `tabLayout -cr true /*-scr true*/ -imh 5 -imw 5 -h 800 palettetab`;

// Animation tab 88888888888888888888888888888888888888888888888888
$animcol = `columnLayout -adj true animcol`;

rowLayout -nc 4
-cw 1 44 -cw 2 44 -cw 3 44 -cw 4 44 ;
intField -ed 0 -w 32 scrolll; //place holder for other controls
intField -ed 0 -w 32 scrollt;
intField -ed 0 -w 32 scrollw;
intField -ed 0 -w 32 scrollh;
setParent..;

//the button "palette" layout
string $animscroll;
$animscroll = `scrollLayout -cr true -h 800 animscroll`;
frameLayout AnimPalette;
gridLayout -autoGrow true -columnsResizable true -cellWidthHeight 100 25 -nr 25 griddy;
setParent..;
setParent..;
setParent..;
setParent..;

// Pose Tab 8888888888888888888888888888888888888888888888888888888
$posecol = `columnLayout -adj true posecol`;

text -l ""; //place holder for other controls
setParent..;

tabLayout -edit -tabLabel $animcol "Animations" -tabLabel $posecol "Poses" $tabs;
scrollLayout -edit -rc "ScrollResizeCommand()" animscroll;
setParent..;
setParent..;
setParent..;

MakeButtons();
showWindow;
ScrollResizeCommand();
}

MakeAWindow();


Just to refresh some memories, I am trying to get a grid of buttons (inside of a tab, which itself is inside of a columnLayout) to display in a screen area that is resizeable, or at least consistent from one animator's machine to the next.

phantastikfan
09-22-2005, 12:57 PM
I want to give my gui a dynamic optionMenu, so the menuItems should change when the user clicks specific controls. I found no hints about flags for optionMenu or menuItems with which I can remove or change the menuItems.

Any Ideas?

Thanks,
phantastikfan

Mikademius
09-22-2005, 02:05 PM
If you want to add controls to a certain layout based on user interaction, see the -p flag (parent). About the updating, I'm not sure. Could just reopen the window in a command, but that wouldn't be a good idea really.

EigenPuff
09-23-2005, 06:05 PM
Here's a quick and dirty sample of what you can do. It gets tricky if you want to replace on specific elements, but if you want to stay simple, try deleting and reconstructing menus in one shot. Otherwise, it'll take a bit of design and forethought to keep it clear and bug-less. Look into the edit flags to see what they allow you to do - good luck.



global proc MakeMenu1()
{
global string $menuname;

//delete the previous menu
menu -e -dai $menuname;

//make a new one
menuItem -p $menuname -l "one";
menuItem -p $menuname -l "two";
menuItem -p $menuname -l "three";


}

global proc MakeMenu2()
{
global string $menuname;
menu -e -dai $menuname;

menuItem -p $menuname -l "uno";
menuItem -p $menuname -l "dos";
menuItem -p $menuname -l "tres";
}


global proc MakeAWindow()
{
global string $menuname;

//if this window exists already, delete it before we create it again
if (`window -q -ex layoutwin`) deleteUI layoutwin;

window -t "menu testing" -mnb on -rtf true layoutwin;
menuBarLayout;
$menuname = `menu -l "file" lemenu`;
setParent..;
columnLayout;
button -l "menu 1" -c "MakeMenu1()" but1;
button -l "menu 2" -c "MakeMenu2()" but2;
setParent..;
setParent..;

showWindow;
}

phantastikfan
09-23-2005, 06:42 PM
Here's a quick and dirty sample of what you can do. It gets tricky if you want to replace on specific elements, but if you want to stay simple, try deleting and reconstructing menus in one shot. Otherwise, it'll take a bit of design and forethought to keep it clear and bug-less. Look into the edit flags to see what they allow you to do - good luck.



That piece of code looks pretty good, thanks, but I think it will only work for the command "option", but I am using "optionMenu" (something like a selectbox) and that does not have the flag -dai (-deleteAllItems) :-(

goleafsgo
09-23-2005, 07:13 PM
If you want to get rid of a menuItem from an optionMenu you could do this...

string $items[] = `optionMenu -q -ill MyOptionMenu`;
deleteUI -menuItem $items[0];

...so you could go through and delete the items and then replace them if you wanted to.

phantastikfan
09-24-2005, 10:06 AM
If you want to get rid of a menuItem from an optionMenu you could do this...

string $items[] = `optionMenu -q -ill MyOptionMenu`;
deleteUI -menuItem $items[0];

...so you could go through and delete the items and then replace them if you wanted to.

I didn't know that there is a command "deleteUI", I think that will work pretty well, thanks for the tip!

bdeda
10-11-2005, 04:07 PM
anyone know how to make this type of control :http://www.crownandtrident.com/images/waveCtrl.jpg


Thanks.

Carina
10-11-2005, 04:16 PM
anyone know how to make this type of control :http://www.crownandtrident.com/images/waveCtrl.jpg


That's a gradientControl, should have an example in the docs (I think, not at my own machine at the moment so can't check!)

Mikademius
10-11-2005, 10:14 PM
Never mind this post:)

jj80
10-22-2005, 09:25 AM
Hi,

Just a quick and stupid question... I'd like to make a status line consisting of 2 lines of text. The textfield element seems to allow only one line (I'm using \r or \n), any ideas ?

Thanks,

Jens

mrtrashtalk
11-29-2005, 08:02 PM
I have written an exporter with the MAYA API. I am using a MEL Script for the export GUI that allows the user to configure the export. The script looks something like this.

-------------------------------------------------------------------------

global proc int exportOptions( string $parent,
string $action,
string $initialSettings,
string $resultCallback )



{

...
...

if ($action == "post") {

//build GUI with controls
...
...

}
else if ($action == "query")
{
//build resultstring with useroptions
$result = 1;
...
}
else
{
$bResult = 0;
}

return $bResult;

return 1;
}

-----------------------------------------------------------------------------

I have a radio button in the GUI. If the user chooses the second option of this button, I want to refresh the GUI and add a checkbox the user can select.

I know how to query the radio button, but what do I have to do to refresh the GUI when the user clicks the radio button ?

Buexe
11-29-2005, 09:11 PM
put a query/refresh procedure on the -changeCommand flag of the appropriate control.

mrtrashtalk
11-29-2005, 09:51 PM
thanks, that was exactly what i needed.

Mikademius
03-30-2006, 01:07 PM
Is there a way to use the gradientControl without attaching it to a ramp? I want to use this control in a UI for the user to set up several values between 0-1 and then I want to query these for use later in a proc. But I don't want to create a node everytime the user wants to use the tool...

:hmm:

goleafsgo
03-30-2006, 02:52 PM
Is there a way to use the gradientControl without attaching it to a ramp?

I think this is what you are looking for...you can "attach" an optionVar which will hold the values of the points in the control. I think that that each entry in the string array will have 3 comma separated numbers which represent the value, position and interpolation type.


global proc checkMyGradValues()
{
print ("\nGetting values from the gradient control...\n");

string $gradPoints[] = `optionVar -q "GradNoAttrCtrlOpVar"`;
for ( $point in $gradPoints )
{
string $values[];
int $n = `tokenize $point "," $values`;
if ( $n != 3 ) continue;

print ("point at position " + $values[1] + " with value " + $values[0] + "\n");
}
}

{
optionVar -rm "GradNoAttrCtrlOpVar";
optionVar -stringValueAppend "GradNoAttrCtrlOpVar" "1,0,1";

window;
columnLayout;
button -command "checkMyGradValues";
gradientControlNoAttr -ov "GradNoAttrCtrlOpVar" GradNoAttrCtrl;
showWindow;
}

Mikademius
03-31-2006, 07:30 AM
I think this is what you are looking for...you can "attach" an optionVar which will hold the values of the points in the control. I think that that each entry in the string array will have 3 comma separated numbers which represent the value, position and interpolation type.


Thank you very much. That's exactly what I'm looking for :bounce:
Why does the query return "value" , "position", "value"? I thought the first one was the ID for the point...

goleafsgo
03-31-2006, 11:21 AM
Why does the query return "value" , "position", "value"? I thought the first one was the ID for the point...
I don't think that there are any "id's" for the points. I'm pretty sure the third number is the interpolation type although I haven't really used it much myself so I could be wrong.

Mikademius
03-31-2006, 11:36 AM
I'll dig into it myself too :) Let you know if I find out something clever.

magilla
07-18-2006, 02:05 AM
re: Cipher
I found these examples in the MAya help for putting a model viewport/camera view into a new window.

// Create a model panel in a separate window.
//
string $window = `window`;
paneLayout;
modelPanel;
showWindow $window;

///////////////////////////////////////////////////////////////and this

// Create a window with a model editor
string $window = `window`;
string $form = `formLayout`;
string $editor = `modelEditor`;
string $column = `columnLayout -adjustableColumn true`;

// Set up the window layout attachments.
//
formLayout -edit
-attachForm $column "top" 0
-attachForm $column "left" 0
-attachNone $column "bottom"
-attachNone $column "right"
-attachForm $editor "top" 0
-attachControl $editor "left" 0 $column
-attachForm $editor "bottom" 0
-attachForm $editor "right" 0
$form;

showWindow $window;

This is cool because I can specify width, height, object visibilty and gate etc for a "Master Camera" view which sits on the second monitor from which to generate all my playblasts. The problem is that I can't playblast from these windows - I can playblast from a torn off panel but not from a panel in a window.

Any suggestions on how to force this?

--magilla

Buexe
07-18-2006, 08:01 AM
Re: magilla
Another thing I have found with this modelEditor in a new window is that if you have the focus on it (it is your "active" window), hotkeys like q, w, e, r, and others don`t work : (
and since I want to build a cool animation interface with this it is really :banghead:
Has anyone a suggestion to solve this ?
TIA

goleafsgo
07-18-2006, 03:17 PM
Another thing I have found with this modelEditor in a new window is that if you have the focus on it (it is your "active" window), hotkeys like q, w, e, r, and others don`t work : (
If you use a modelPanel and not just a modelEditor does it work?

goleafsgo
07-18-2006, 03:24 PM
The problem is that I can't playblast from these windows - I can playblast from a torn off panel but not from a panel in a window.
I didn't have any problem doing a playblast from a window like that. I am doing it on a single monitor though...I guess it could be a multi-monitor problem?

Buexe
07-18-2006, 03:40 PM
If you use a modelPanel and not just a modelEditor does it work?

DINGDINGDING

And the winner is ..... goleafsgo!
:applause:

Cool it works finally!
Thank you so much!

magilla
07-19-2006, 10:24 PM
cool, a modelPanel does the trick with the playblast, but I am having trouble slotting it into a window with buttons using the form layout described above. I assume I need to escape that with a setParent and use paneLayout perhaps? When I tried this the viewport was itty-bitty - I'm guessing because it's no longer constrained by the formLayout. If I try to slot the panel in the columnLayout it errors with "too many children". Can anyone offer some example code please?

Of course, this leads me to also ask; why have a modelPanel and a modelEditor in the first place, since the modelPanel is a window containing a modelEditor?

man, this stuff confuses the hell out of me...

--magilla

Buexe
07-20-2006, 08:12 AM
I use a tabLayout with the -childResizable flag true above the formLayout so that the formLayout changes it`s size when the window it resides in is resized.

But I asked myself the same question about the modelEditor and modelPanel, must be something technical I guess.

StefanStavrev
08-17-2006, 08:16 PM
Hey guys

I am mel beginner.I suppose this is a simple one so...

I searched the MEL reference and found nothing about how to create a color chooser.I also tried to get some script with echo all commands but nothing...

So what should i do so when i press a button in my window script a color chooser to be activated ?

If you got something on that topic please share...

Cheers :)

JBarrett
08-17-2006, 10:48 PM
Hey guys

I am mel beginner.I suppose this is a simple one so...

I searched the MEL reference and found nothing about how to create a color chooser.I also tried to get some script with echo all commands but nothing...

So what should i do so when i press a button in my window script a color chooser to be activated ?

If you got something on that topic please share...

Cheers :)

The command you want is "colorEditor". Look it up in the MEL Command Reference and it'll have details on its use.

StefanStavrev
08-17-2006, 10:53 PM
Thanks Bro :)

lutzd
08-30-2006, 10:26 PM
I'm make a temp Gui for a Publish tool. But i want to add a text field to a button.
So when you hit the button a text field put up to tell what that button will do.

I'm not a mel guy just building a mock up interface for a tool.

Also were going to look for a Mel/TD guy to build this tool (Don't need to be in house for it). So if you have experience with PipeLine Tools . Let me know, THIS IS A PAYING GIG

but first need help with the top question

I work for www.intelligentcreatures.com

magilla
08-31-2006, 01:33 AM
you can add the flag

-annotation "Insert Tooltip here"

to the button command, I think this is what you're after.

-=magilla=-

lutzd
08-31-2006, 04:59 PM
thanks for the feedback
This scirpt well put the text in the comand line. Now is there a way to make the text show up it the tool it self.(ie add a text feild or make a custom comand line in the tool at the bottom or something) I just want to make sure that when you hit the button It tells you what its doing.

This is for when im ready to get the tool made by someone, that they have a good idea of what it is ment to do.

Thanks

Mikademius
08-31-2006, 05:08 PM
thanks for the feedback
This scirpt well put the text in the comand line. Now is there a way to make the text show up it the tool it self.(ie add a text feild or make a custom comand line in the tool at the bottom or something) I just want to make sure that when you hit the button It tells you what its doing.

This is for when im ready to get the tool made by someone, that they have a good idea of what it is ment to do.

Thanks

Yes there is. I can give you some examples. Let's continue this via pm ;)

lutzd
09-06-2006, 11:08 PM
so if i want to put some stuff in my shelfTabLayout how would i go about that.
Say i want to add a few checkbox and a button that runs the length of the window.

Im new not a mel guy just trying to do some stuff.
thanks



string $window_name = `window -title "IC Publish"
-menuBar true
-widthHeight 483 500`;

columnLayout icTitle;
iconTextStaticLabel -style "iconAndTextHorizontal" -i "L:\\ic_logo\\IC_logo_Publish.xpm" -w 483 -h 100 -label "ic Publish Manager";

setParent ..;
setParent ..;


shelfTabLayout

-imageVisible true mainShelfTab ;
shelfLayout Modeling ;
setParent ..;
shelfLayout Texturing;
setParent ..;
shelfLayout Tracking;
setParent ..;
shelfLayout Animation;
setParent ..;
shelfLayout Lighting;
setParent ..;
shelfLayout Rendering;


setParent ..;
setParent ..;

frameLayout -labelVisible false -label "HelpLine" -width 475;

helpLine;

setParent ..;
setParent ..;

showWindow $window_name ;

Greken
09-21-2006, 07:50 PM
Does anyone know the mel-command for that textScrollList-look-alike in the Connection Editor? I have been trying to find the mel-file containing the UI, but haven't succeded yet.

Regards,
Pedalen

Buexe
09-21-2006, 07:56 PM
Does anyone know the mel-command for that textScrollList-look-alike in the Connection Editor? I have been trying to find the mel-file containing the UI, but haven't succeded yet.

Regards,
Pedalen

outlinerEditor?

Greken
09-21-2006, 08:12 PM
outlinerEditor?

Ah, actually I was thinking of that command as well but since the visual appearance was a bit different I thought it was not. But now that I tried to right click and chose Show Attributes I got it to look just like I wanted :P Thanks man!

Regards,
Pedalen

ljilekor
11-08-2006, 09:13 AM
An unconvenient truth... I'm lazy. I guess I'm not alone...:wise:

So I prefer to spend my time doing the reeel coding. Not inventing all kinds of coding mumbojumbo to create a UI (unless its something special). Most of the time I just need to build an interface made of the basic stuff ( strings/ floats/ checkers/ radiobuttons/ choicelists/ ... ) To perform those simple tasks, I think there's nothing easier than the visual approach.

In 3DSMax building UI's is a real breeze thanks to the visual approach. I found some stuff for MEL but nothing that's really good or can match with MaxScript Visual UI builder. MEL exists for 6-7 years now... ? I checked the Mel_UI_Builder1.6 but... To be honest, it kinda sucks compared to what MAX has to offer(although its something:rolleyes: ). There MUST be something of that kind that works really well... ???:curious:

Is there a kick ass visual UI builder for MEL or does it still has to be invented?:banghead:

Thx.

magilla
11-08-2006, 11:34 PM
There were a couple of likely contenders but they all seemed to have some major problems.

Lately I've been using UIDesigner - which is very clunky but I can knock something out very quickly

I used to use Melanie but it crashed constantly and annoyed the heck out of me because it was a standalone app.

I'm surprised there hasn't been more development in this area.

==magilla

ljilekor
11-09-2006, 09:49 AM
Thx a lot Magilla.

I'm testing the UIDesigner...

It's kinda crappy too but I can live with it. The biggest problem with it is the fact that it generates errors in the MEL output code... (commands missing/switching labels and names/ etc). So I need to debug the code and clean it up...

I haven't tried Melanie yet. (:p). Lost too much time already. But I will. She better be good to me once I do her:wip:.


I'm surprised there hasn't been more development in this area.
Apparently everybody loves scripting interfaces. It's the summum of satisfaction. A very creative process. They should organise a contest for who can script the nicest interfaces and publish it in expose...

Can I write scripts with my wacom ??? :bounce: :bounce:


Sorry, I'm just a little dissapointed... Thanks again Magilla.

CraigHorne
11-17-2006, 08:55 AM
QUOTE--------

GUI Builder
I've put together a mel script that works as an editor for user interfaces. It has over 32 controls in it and 8 layouts as well. I wasn't sure if this would be the best place to post this but I've found this script really sped up manufacturing UI. I'd love to get some feed back on this script and see how you guys like it.

http://www.3dsetup.com/scripts/guiBuilder.mel

Yours truly,
Michael Clavan
www.3dsetup.com (http://www.3dsetup.com/)
mc@3dsetup.com (http://forums.cgsociety.org/mc@3dsetup.com)


QUOTE--------


this tool is really fantastic. not only for production, but as a learning tool. Thanks

craig

ManiaX
01-17-2007, 09:42 AM
well,

i just wrote this ui-builder.
you model the ui-layout in maya viewport. the script takes the maya units and hierarchy to generate the ui-mel-script.
the transformname defines the ui-item type ( window0 e.g. )
and the shape-name defines the ui-item name ( mywindowShape e.g. )
the ui flags are added as dynamic (custom) attributes and can be changed via my ui-generating-ui.

the first attachements shows the ui.
the second attachement is the script...

have fun,

moe

m0rales
02-01-2007, 04:49 PM
****ing sweet man, well done :D

Gonna give it a go ;)

katisss
02-28-2007, 12:16 PM
How would i update the color of a button in my UI without using a ScriptJob
or updating the entire window?

window; columnLayout;

string $button = `button -label "Color Me"`;

button -edit

-command ("evalDeferred \" button -e -bgc 0 1 1 " + $button + "\"") $button;

showWindow;

works but the update speed is a bit unpredictable. Is it possible?


I am also looking for a way to save presets/parameters for my ui.

ManiaX
03-01-2007, 08:14 AM
hi,

that's a common problem in maya-ui.
in order to change the color correctly you have to change the text, or an other
parameter ( e.g. height ) as well.

greetz, moe

katisss
03-01-2007, 08:54 AM
Very stupid, thanks for leting me know.

deadalvs
03-08-2007, 06:35 PM
hey there...

small question.

if i have a formLayout with three buttons. how can i grey out/inactivate/make invisible button number two (alone without hiding the whole formLayout) ?

thanks...

drmerman
03-08-2007, 09:00 PM
Hey deadalvs.

Wait a minute...where are we? :scream:

After you've created your button, you need to edit the -enable flag, like this :

window -width 150 myWindow;
columnLayout;
button -label "Enabled" -w 60 firstButton;
button -label "Disabled" -w 60 secondButton;
button -label "Enabled" -w 60 thirdButton;


button -e -en 0 secondButton;

showWindow myWindow;

deadalvs
03-08-2007, 09:04 PM
now that's a surprise... :)

* * *

yeah, since i'm pretty p****d off of the «other» forum, i thought i'd just rewrite my copying script to cool down...

now i tried to work with formLayouts... i think this will be also a cool script ! yay !

thanks for the tip, i'll use it !

drmerman
03-08-2007, 09:28 PM
No worries mate :thumbsup: I'm actually just putting the finishing touches on that procedural script. Should be up tomorrow morning, with added MXM/Anim export. It's a complete b**ch, but should keep people going until 1.2 comes out :D

And form layouts are definitely the way forwards. I usually end up having groups of controls in their own formlayout (for instance, 3buttons.) I then put that layout into another layout, so you can move the buttons as a group, and they'll keep the nice spacing you spent ages setting up :)

Good luck!

Cheers,
Dr Merman

animaxforever
09-04-2007, 02:49 PM
hey guys,

do anyone know how to give a tooltip for a button control? like when u hover on the button it should show a tip of what it's function is..

deadalvs
09-04-2007, 02:58 PM
good question. this must work because maya's normal UI does have that funcion too... i just never searched for it though...

ManiaX
09-05-2007, 10:00 AM
you just have to use the flag "-annotation".
example:

button -label "bla" -annotation "helptxt" buttonName;

the annotation is seen in the helpline at the bottom of the main ui, too.
sometimes the bubblehelp is turned off...

animaxforever
09-12-2007, 09:26 AM
you just have to use the flag "-annotation".
example:

button -label "bla" -annotation "helptxt" buttonName;

the annotation is seen in the helpline at the bottom of the main ui, too.
sometimes the bubblehelp is turned off...



thanx for the reply maniax... i tried the annotation flag.... as u said it comes ONLY at the help line not as a tool tip...and where can i turn on the bubble help?

ManiaX
09-13-2007, 09:49 AM
you should find a checkbox under Window>Settings/Preferences>Preferences|Interface|Help:
Tool messages > enable;
but this is not save anyway. i don't get any bubblehelp as well.
sometimes it's there somtimes not....

animaxforever
09-15-2007, 10:59 AM
thanx ManiaX..

you are right... the "-annotation" flag works both for help line and tool tip...if tool tip is not on in the preferences then it shows at the help line other wise we can see it as a tool tip...


thanx a lot..

mrtrashtalk
11-29-2007, 04:49 PM
Hi,

I have written an exporter for Maya a while ago . It uses the Maya API and works quit well, but I would like to make it more convenient for the user.

So everytime the user loads the plugin, I would like to add a panel to each transform node and material node in the attribute editor. With these panels the user can set attibutes that I will store as extra attributes. E.g. the user can select a special shader node the exporter uses, not by adding a string extra attribute manually, but by clicking a preview thumbnail for this shader node.

Can I do this (adding custom panels to the attribute editor), or can the attribute editor only display nodes and attibutes that actually exist ?

animaxforever
01-10-2008, 05:09 PM
anyone heard about this??

Neoreel online MEL library..is a free plugin, which has a wonderful tool called visual ui builder...which is really nice for fast ui building ...check it out
http://www.neoreel.com/library/

kuschel33
04-22-2008, 12:38 PM
I want to create a set of buttons dynamicaly! Let me explain...

I have my tree in outliner:
-geo-
-plastic-
-material1-
-material2-
-material3-
-metal-
-material4-
-material5-
-wood-
-material6-
-material7-
-material8-
...
From that tree I want to create buttons in my UI.
--> plastic would be a text --> under this "headline" it creates 3 buttons labeled "material1", "material2", ...
--> next "headline" --> button creation --> ...

My problem is to find out the nodes/groups under -geo- and of course the materials under their "headline"-node (plastic, etc.)

I hope some of you understand my problem. :D Thanks in advance!

Norb
05-02-2008, 06:55 PM
This is generally how to do it...I've left out any error checking, so it'll just break if you don't have an object named 'GEO'



global proc makeWindow()
{
string $sGeoNode = "GEO";
string $saMatTypes[] = `listRelatives -children $sGeoNode`;

string $sWin = "mw_UI";
if (`window -q -exists $sWin`)
deleteUI $sWin;

window -w 200 -h 500 -rtf 1 $sWin;

for ($sMatType in $saMatTypes)
{
columnLayout ($sMatType+"_colName");
string $saMaterials[] = `listRelatives -children $sMatType`;
text -l $sMatType ($sMatType+"_textLabelName");

for ($sMaterial in $saMaterials)
{
button -l $sMaterial ($sMaterial+"_buttonName");
}
}

showWindow $sWin;
}

makeWindow;

Byron
05-12-2008, 11:11 PM
Usually MEL Interfaces can become quite complex - this renders them hard to understand at first as the UI layouts are nested into a hierarchy.

This hierarchy is usually not represented visually by the code itself, but its only indicated by "setParent" statements.
Not only that this makes the reading ( and thus maintenance ) more difficult, but it can easily cause errors during development too due to forgotten and misplaced "setParent" statements.

The following code example shows how the scope operator is used to directly represent the underlying layout hierarchy. It also shows how the UI has been split up into sub-areas that are handled by respective functions - this helps not to distract from the actual structure/layout of the UI and facilitates reading.

Regards,
Byron


string $mainForm =
// -------------------------------
`formLayout (mainLayout($id))`;
// -------------------------------
{
int $valuePercent = 30
string $mainPane =
// -----------------------------------------
`paneLayout -configuration "vertical2"
-ps 1 ($valuePercent) 100
(mainPane($id))`;
// -----------------------------------------
{
// hide or show the respective portion
// This will make look everything much better

if( $valuePercent == 0 )
{
// CONTENT FORM
// --------------------------------------------------
string $content = createContentForm( $id, $opts );
// --------------------------------------------------

// OUTLINER
// --------------------------------------------------
string $outliner = createOutlinerForm( $id, $opts );
// --------------------------------------------------
}
else
{
// OUTLINER
// --------------------------------------------------
string $outliner = createOutlinerForm( $id, $opts );
// --------------------------------------------------

// CONTENT FORM
// --------------------------------------------------
string $content = createContentForm( $id, $opts );
// --------------------------------------------------
}


}// END MAIN PANe
setParent ..;


// BOTTOM LINE AREA
// --------------------------------------------------
string $lines = createLineForm( $id, $opts );
// --------------------------------------------------


int $m = 2;
formLayout -e
-af $mainPane "top" $m
-af $mainPane "left" $m
-ac $mainPane "bottom" $m $lines
-af $mainPane "right" $m

-an $lines "top"
-af $lines "left" $m
-af $lines "bottom" $m
-af $lines "right" $m
$mainForm;

}// END MAIN FORM
setParent ..;

ewerybody
05-13-2008, 10:37 AM
Hey Byron! Nice to read from you! :)

Yea! I do that UI-indentation as well in the code but only without the {}!
But surely melstudio for instance would take some work from you if you'd do so. I mean type { and the next line is automatically indented... plus you have bracket-highlighting!

hmm... I'm thinkin about that when scripting next time ;]

wow, I took a look at your website now. seems you have something really huge up your sleeve!

sabungero
06-19-2008, 08:25 AM
hi there...anybody knows how i can put a BG image on my mel window? i want to make it look fancy and cute

ewerybody
06-19-2008, 10:30 AM
I once hacked together a test with a completely custom button and background: I never really used it but seems it works:

window kasgkfWin;
formLayout -w 300 -h 300 hbresavaForm;
shelfButton -w 100 -h 100 -marginWidth 0 -marginHeight 0
-image "test_n.bmp"
-highlightImage "test_h.bmp"
-selectionImage "test_p.bmp"
-command "print\"HUHU!\\n\""
owahButton;
image -w 300 -h 300 -image "C:/Do ...MAYAUSERFOLDER... /maya/7.0/prefs/icons/test_bg.bmp"
qwdfqwfBG;
setParent ..;
formLayout -edit
-af owahButton top 99
-af owahButton left 99
-af qwdfqwfBG top 0
-af qwdfqwfBG left 0
hbresavaForm;
window -e -w 300 -h 300 kasgkfWin;
showWindow kasgkfWin;


Trick is to set the image after the button! this way its kept in background for some reason.
The paths to the shelftButtons images could be set relatively. That seemed not to work for the background image. But try for yourself. I think you'd manage to create a background and the button images. _n is for normal state, _h for mouseover and _p for pressed.

sabungero
06-20-2008, 08:25 AM
thanks! exactly what i needed :D can i buy you a beer?

ewerybody
06-20-2008, 10:00 AM
sure! :beer: cheers!

Pyrokinesis
08-16-2008, 01:58 AM
Hello,
Im building a GUI and looking for a control to initiate the fileBrowser command. I know that I can create my own button and have it execute the fileBrowser command, but I thought that if maya has a premade control...that would be nice.

ps, Im on Linux and finder; is deffinately not what Im after.

Thanks.

Pyrokinesis
08-18-2008, 12:15 AM
Created my own thx

ewerybody
08-18-2008, 10:01 AM
how did you do it?
screenshot or it didn't happen! :D

Pyrokinesis
08-24-2008, 12:34 PM
I used a textField and a symbolButton.

mayaartist
08-26-2008, 05:32 PM
Great stuff here guys, I know this is a sticky thread so I thought I would say that a couple posts with links on the first page don't even exist anymore.

Maybe we should do a new sticky thread with Python and MEL integration.

Konata
08-27-2008, 11:18 AM
Hi!

I made a mel script with three "symbolCheckBox" (Edit: sorry!). I like reset the other buttons to default value (off) when I turn on one button but I can't do it..

Example:
Press Button1 -------> Button2 and Button3 turn off

Thanks!

NaughtyNathan
08-27-2008, 12:51 PM
Hi!

I made a mel script with three "symbolButton". I like reset the other buttons to default value (off) when I turn on one button but I can't do it..

Example:
Press Button1 -------> Button2 and Button3 turn off

Thanks!

symbolButtons don't have an "off" status..?! do you mean symbolCheckBox? or do you mean you want to disable them..?

well, either way, your buttons have a press command right? so, in the command for button1 you just do something to the other buttons (using the -edit flag)...

for example:

symbolButton -c "symbolButton -e -vis 0 myButton2;symbolButton -e -vis 0 myButton3" myButton1;
symbolButton myButton2;
symbolButton myButton3;

this would create 3 symbol buttons, pressing the first makes the second and third invisible.
:nathaN

Ahikhu
08-27-2008, 12:56 PM
oops... ...

Konata
08-27-2008, 08:02 PM
Sorry NaughtyNathan! I'm wrong, my buttons are "symbolCheckBox".

My problem is this, I Press button1:

[Button1] ON
[Button2] OFF
[Button3] OFF

Then I press Button2:

[Button1] ON -> I like this button turn off when I press Button2 (the same with button3)
[Button2] ON
[Button3] OFF

NaughtyNathan
08-28-2008, 10:15 AM
well you just do the same thing with each button command.. turn the others off...

but it sounds like what you want is RADIO BUTTON behaviour.. there's no point manually hacking in a behaviour system that's already present... don't use symbol buttons, use iconText...Buttons as they are more versatile.

Take a look at iconTextRadioButton as this will probably be better for what you want.

:nathaN

Konata
08-29-2008, 09:22 PM
well you just do the same thing with each button command.. turn the others off...

but it sounds like what you want is RADIO BUTTON behaviour.. there's no point manually hacking in a behaviour system that's already present... don't use symbol buttons, use iconText...Buttons as they are more versatile.

Take a look at iconTextRadioButton as this will probably be better for what you want.

:nathaN

Thanks! iconTextRadioButton works perfect!

Konata
09-02-2008, 09:38 AM
Hello again! (sorry, 'i'm very noob in mel script '_')

I have a checkbox and one button. I like change the command button when checkbox is on or off.

For example:
[checkbox ON] -> Button command: setKey;
[checkbox OFF] -> Button command: BreakdownKey;

Buexe
09-02-2008, 09:47 AM
Hello again! (sorry, 'i'm very noob in mel script '_')

I have a checkbox and one button. I like change the command button when checkbox is on or off.

For example:
[checkbox ON] -> Button command: setKey;
[checkbox OFF] -> Button command: BreakdownKey;

I would add a proc to the -changeCommand flag that basically queries the state of the checkBox and saves this in an optionVar. Than in your button command query the optionVar to know if the user wants a key or a breakdown. The advantage of storing it in an optionVar is, that you can retrieve this info later, even in a new maya session to restore your GUI to the configuration the user has used it the last time. I hope that makes sense.

Konata
09-02-2008, 11:17 AM
I would add a proc to the -changeCommand flag that basically queries the state of the checkBox and saves this in an optionVar. Than in your button command query the optionVar to know if the user wants a key or a breakdown. The advantage of storing it in an optionVar is, that you can retrieve this info later, even in a new maya session to restore your GUI to the configuration the user has used it the last time. I hope that makes sense.

Thanks Buexe! I'm trying use the optionVar and -changeCommand but I can't do it. I'm very noob. Can you write a short example? or any web information where I can learn the basic.

NaughtyNathan
09-02-2008, 11:30 AM
here's one way of doing it... personally, I'd do it a slightly more sophisticated way than this, but this is the simplest way I could think to explain it as you do seem to be having trouble with a controls -c "" flag...

global proc doFunction()
{
int $isOn = `optionVar -q myOptionVarA`;

if ($isOn)
{
// do the thing that happens when the checkbox is ON
}
else
{
// do the thing that happens when the checkbox is OFF
}
}
checkBox -v `optionVar -q myOptionVarA` -cc "optionVar -iv myOptionVarA #1";
button -c "doFunction";

hopefully you can decipher this easily enough.. The only confusing bit is the #1.. this simply represents the controls value (i.e. on or off), so every time the checkbox is changed (-cc) the optionVar is set the the checkboxes current value (#1)

:nathaN

Buexe
09-02-2008, 11:31 AM
Thanks Buexe! I'm trying use the optionVar and -changeCommand but I can't do it. I'm very noob. Can you write a short example? or any web information where I can learn the basic.

Alright, this is for example your GUI:

global proc myGUI ()
{
//bla bla, create layouts etc

global string $myCheckBox;
$myCheckBox = `checkBox -cc changeCheckboxProc`;
button -command myButtonCmd;
// bla bla, rest of GUI
}


Now when you click on you checkbox this proc will fire and store the optionVar
global proc changeCheckboxProc()
{
global string $myCheckBox;
int $value = `checkBox -q $myCheckBox`;
optionVar -iv $value myOptionVar;
}


This is your button command which will query the optionVar
global proc myButtonCmd()
{
int $value = `optionVar -q myOptionVar`;
print ("CheckBox state: " + $value + "\n");
}



I hope this helps

NaughtyNathan
09-02-2008, 11:34 AM
shame on you Buexe, for encouraging a n00b to use global variables!! *tsk* :D ;)

Konata
09-02-2008, 11:38 AM
Thanks! :P

Buexe
09-02-2008, 06:07 PM
shame on you Buexe, for encouraging a n00b to use global variables!! *tsk* :D ;) didn´t do it on purpose, guess i should turn off my auto-pilot once in a while : )

Konata
09-03-2008, 05:18 PM
Hello again! :$

How can I create this "tab scroll"?

http://img79.imageshack.us/my.php?image=tabspl5.jpg

Thanks!

RavenEye
09-11-2008, 03:49 PM
I'm trying to add a menu to the mainWindow menus. I'm able to get it up there but I would like for it to be up there on start-up. I don't know what to add to the userPrefs.mel to call upon the script that adds the menu to the mainWindow on start up. I would like some assistance in this matter, please.

Buexe
09-11-2008, 04:11 PM
I'm trying to add a menu to the mainWindow menus. I'm able to get it up there but I would like for it to be up there on start-up. I don't know what to add to the userPrefs.mel to call upon the script that adds the menu to the mainWindow on start up. I would like some assistance in this matter, please.

create a proc that adds your menu and add the name of that proc to the userSetup.mel file in some script dir Maya can find. Create a file with this name if there is not already one.

=LuxX=
09-22-2008, 11:03 AM
dear MEL ppls.

I am strugling with the layout. could any one help me with this plz?

window -t "controls" -resizeToFitChildren true;
rowLayout -numberOfColumns 5 ;
columnLayout -columnAttach "both" 12 -rowSpacing 8 -columnWidth 400;
setAttr "Craneturn.rotateY" 0;

string $mainturn;
$mainturn = "Craneturn";
attrFieldSliderGrp -l "Main rotate" -min 0 -max 360 -at ($mainturn+".ry");

string $Lift;
$lift = "Liftingcontrol";
attrFieldSliderGrp -l "Lifting" -at ($lift+".LIFTING");

string $Mainhooklow;
$Mainhooklow = "grotehaak";
attrFieldSliderGrp -l "Main hook LOW" -at ($Mainhooklow+".Grote Haak");

string $Mainhookrot;
$Mainhookrot = "mainhookrotate";
attrFieldSliderGrp -l "Main hook ROT" -at ($Mainhookrot+".Mainhookswing");

string $smallhooklow;
$smallhooklow = "kleinehaak";
attrFieldSliderGrp -l "kleine hook LOW" -at ($smallhooklow +".kleinelower");

string $smallhookrot;
$smallhookrot = "kleinrotate";
attrFieldSliderGrp -l "kleine hook ROT" -at ($smallhookrot +".smallsling");

string $trollyslide;
$trollyslide = "trollycontrol";
attrFieldSliderGrp -l "Trolly slider" -at ($trollyslide +".trollyupdown");

setParent ..;
columnLayout -columnAttach "right" 2 -rowSpacing 8 -columnWidth 100;
button -l "select" -w 100 -c "select -r Craneturn";

setParent ..;

columnLayout -columnAlign "both" -rowSpacing 8 -columnWidth 100;

button -l "key" -w 100 -command "setKeyframe Craneturn";

setParent ..;

showWindow;


I f i test this then the sliders are oke but the SELECT button and the KEY button are on the top slider. but i want them to be to the right of that slider.
how can i do that?

goleafsgo
09-22-2008, 02:03 PM
dear MEL ppls.

I am strugling with the layout. could any one help me with this plz?

...

I f i test this then the sliders are oke but the SELECT button and the KEY button are on the top slider. but i want them to be to the right of that slider.
how can i do that?


There are usually more than a few ways to lay out a UI but I think the smallest change that you could make to get things going would be to change your rowLayout call to this:


rowLayout -numberOfColumns 3
-adjustableColumn 1
-columnAlign 1 "left"
-columnAttach 1 "left" 0
-columnAttach 2 "left" 0
-columnAttach 3 "left" 0;

=LuxX=
09-22-2008, 02:13 PM
I dont get it...

window -t "controls" -resizeToFitChildren true;
columnLayout;

rowLayout -numberOfColumns 3
-adjustableColumn 1
-columnAlign 1 "left"
-columnAttach 1 "left" 0
-columnAttach 2 "left" 0
-columnAttach 3 "left" 0;
setParent ..;
setAttr "Craneturn.rotateY" 0;
string $mainturn;
$mainturn = "Craneturn";
attrFieldSliderGrp -l "Main rotate" -min 0 -max 360 -at ($mainturn+".ry");

ETC ETC> ...

it stays the same as before? ... and what does the 0 mean at the end of the lines

Felous
10-22-2008, 05:46 PM
How can you create a floating window that will pop-up at your mouse's pointer position (when key is pressed) and is there a way to make it vanish by pressing the same keystroke that made it appear or something similar ?

ewerybody
10-23-2008, 12:22 AM
Unfortunately there is no simple way (and simply no way with MEL-only) of determing the current cursor position. But you can create custom popupMenus under the mouse cursor no prob!

Felous
10-23-2008, 12:54 AM
Unfortunately there is no simple way (and simply no way with MEL-only) of determing the current cursor position. But you can create custom popupMenus under the mouse cursor no prob!Cool ! What do you mean when you say popupMenus, though ?

Appreciate the reply.

ewerybody
10-24-2008, 07:35 PM
have a look at the popupMenu docs or maybe try that:

opens a window clicking left or right anywhere in the window pops up a menu under the cursor:
window;
columnLayout;
popupMenu -button 1;
menuItem;
menuItem -divider 1;
menuItem;
menuItem;
popupMenu -button 3 -markingMenu 1;
menuItem -radialPosition N;
menuItem -radialPosition W;
menuItem -radialPosition E;
menuItem -radialPosition S;
menuItem;
showWindow;

Its a window with columnLayout but actually you can put a popupMenu to any control or layout in Maya!

Felous
10-26-2008, 05:52 PM
Thanks a ton ewerybody !

Sorry it took a little bit to reply but I was trying to mess with it a little more before I did. But now, I've been trying more to switch the track/pan from alt+mmb to alt+rmb. So, I've just started reading some C++ to see if I could use it for this situation.

But when I'm done with that (hopefully I will get it done-lol), I will focus more on windows ! I appreciate your help.

=LuxX=
11-03-2008, 02:03 PM
string $example_window = `window`;

string $example_form = `formLayout -numberOfDivisions 100`;

string $Ftrust_grp = `floatSliderGrp -l "draai"

-field false

minValue 0.0 -maxValue 10.0

string $Ftrustsel = `button -l "SELECT"`;

string $Ftrustkey = `button -l "KEY"`;

formLayout -edit

-attachPosition $Ftrust_grp "top" 10

-attachForm $Ftrust_grp "left" 10

-attachNone $Ftrust_grp "bottom"

-attachForm $Ftrust_grp "right" 10

-attachPosition $Ftrustsel "top" 20

-attachForm $Ftrustsel "left" 10

-attachNone $Ftrustsel "bottom"

-attachForm $Ftrustsel "right" 10

-attachPosition $Ftrustkey "top" 30

-attachForm $Ftrustkey "left" 10

-attachNone $Ftrustkey "bottom"

-attachForm $Ftrustkey "right" 10

$example_form;

showWindow $example_window;

gives me the next error?

// Error: string $Ftrustsel = `button -l "SELECT"`; //

// Error: Line 6.17: Syntax error //

why?

goleafsgo
11-03-2008, 02:23 PM
It looks like you are missing the "-" in front of the minValue/maxValue flags, and the `; at the end of that floatSliderGrp call.

After that you might have some typos in the longer formLayout call...eg. I think the attachPosition flag takes 2 integers at the end.

=LuxX=
11-03-2008, 02:51 PM
thnx but thats not it.. it has to something with the select line:

string $Ftrustsel = `button -l "SELECT"`;

// Error: string $Ftrustsel = `button -l "SELECT"`; //

// Error: Line 6.6: Syntax error //

goleafsgo
11-03-2008, 03:47 PM
Are you sure? Have you copy/pasted exactly what you are running? Because without the "`;" at the end of the minValue line, it will continue on till the end of that button line and would spit out just that kind of error.

=LuxX=
11-03-2008, 03:59 PM
ow stupid me i forget to put the ; at the end.. now it goes further but then i get the next fault



string $example_window = `window`;

string $example_form = `formLayout -numberOfDivisions 100`;

string $Ftrust_grp = `floatSliderGrp -l "draai"

-field false

-minValue 0.0 -maxValue 10.0`;

string $Ftrustsel = `button -l "SELECT"`;

string $Ftrustkey = `button -l "KEY"`;

formLayout -edit

-attachPosition $Ftrust_grp "top" 10

-attachForm $Ftrust_grp "left" 10

-attachNone $Ftrust_grp "bottom"

-attachForm $Ftrust_grp "right" 10

-attachPosition $Ftrustsel "top" 20

-attachForm $Ftrustsel "left" 10

-attachNone $Ftrustsel "bottom"

-attachForm $Ftrustsel "right" 10

-attachPosition $Ftrustkey "top" 30

-attachForm $Ftrustkey "left" 10

-attachNone $Ftrustkey "bottom"

-attachForm $Ftrustkey "right" 10

$example_form;

showWindow $example_window;

// Error: line 25: Error while parsing arguments. //

but thnx so far it helped :D but you also know why i get this last message?
(line 25 is the last one)

goleafsgo
11-03-2008, 04:27 PM
I think the "-attachPosition" flags take "string string int int" as arguments, but you only have 1 int in your call.

=LuxX=
11-05-2008, 10:04 AM
aah thnx again ..
i changed a lot since last post .. but now my window wont show..
but the wierd thing is:
window -title "Form Stuff";

string $type = `formLayout -numberOfDivisions 100`;

*** bla bla bla stuff***

$type;

showWindow;

****** in 1 script this works and in the other script i get an error.
// Error: line 53: Error while parsing arguments. //

goleafsgo
11-05-2008, 03:00 PM
The "error while parsing arg's" part you will get if you have something wrong with the formLayout call. I would try a shorter version of the formLayout call until you find the lines that are causing the problem.

Norb
11-05-2008, 07:09 PM
your -attachPosition lines should look like this:


-attachPosition $Ftrust_grp "top" 10 10

=LuxX=
11-11-2008, 01:45 PM
oki guys thnx for the help :D

my UI is almost done now .

string $test_window = `window`;
string $form = `formLayout -numberOfDivisions 100`;
//-----------------------------
string $trustLv = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor4.rotateZ -l "truster LV"`;
string $trustLvSel = `button -l "SELECT" -command select trustvoor4`;
string $trustLvKey = `button -l "POI"`;
//----------------------------
string $trustRv = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor2.rotateZ -l "truster RV"`;
string $trustRvSel = `button -l "SELECT" -command select trustvoor2`;
string $trustRvKey = `button -l "POI"`;
//----------------------------
string $trustLvB = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor3.rotateZ -l "truster LV2"`;
string $trustLvBSel = `button -l "SELECT" -command select trustvoor3`;
string $trustLvBKey = `button -l "POI"`;
//----------------------------
string $trustRvB = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor1.rotateZ -l "truster RV2"`;
string $trustRvBSel = `button -l "SELECT" -command select trustvoor1`;
string $trustRvBKey = `button -l "POI"`;
//----------------------------
string $luikopn = `attrFieldSliderGrp -min -5 -max 0 -attribute Luikopener.translateX -l "Open luik"`;
string $openSel = `button -l "SELECT" -command select Luikopener`;
string $trdown = `attrFieldSliderGrp -min -6 -max 0 -attribute TrustersVOOR.translateY -l "Trusters Down"`;
string $trdownSel = `button -l "SELECT" -command select TrustersVOOR`;
//----------------------------
string $turnLmid = `attrFieldSliderGrp -min -180 -max 180 -attribute Ltrust.rotateY -l "ROT L"`;
string $turnLmidSel = `button -l "SELECT" -command select Ltrust`;
string $turnRmid = `attrFieldSliderGrp -min -180 -max 180 -attribute Rtrust.rotateY -l "ROT R"`;
string $turnRmidSel = `button -l "SELECT" -command select Rtrust`;
//----------------------------------
string $schroefLmid = `attrFieldSliderGrp -min -20 -max 20 -attribute SchroefL.rotateX -l "ROT Schroef"`;
string $schroefLmidSel = `button -l "SELECT" -command select SchroefL`;
string $schroefRmid = `attrFieldSliderGrp -min -20 -max 20 -attribute SchroefR.rotateX -l "ROT Schroef"`;
string $schroefRmidSel = `button -l "SELECT" -command select SchroefR`;
//-----------------------------------
string $trustLacht = `attrFieldSliderGrp -min -180 -max 180 -attribute trusterLachter.rotateY -l "Schroef L achter"`;
string $trustLachtSel = `button -l "SELECT" -command select TrusterLachter`;
string $TrustRacht = `attrFieldSliderGrp -min -180 -max 180 -attribute TrusterRachter.rotateY -l "Schroef R achter"`;
string $trustRachtSel = `button -l "SELECT" -command select TrusterRachter`;
//-----------------------------------
string $schroefLacht = `attrFieldSliderGrp -min -20 -max 20 -attribute sturenL.rotateX -l "ROT Schroef"`;
string $schroefLachtSel = `button -l "SELECT" -command select schroefLacht`;
string $schroefRacht = `attrFieldSliderGrp -min -20 -max 20 -attribute sturenR.rotateX -l "ROT Schroef"`;
string $schroefRachtSel = `button -l "SELECT" -command select schroefRecht` ;
//------------------------------------
string $unselect = `button -l "Unselect" -c "select -cl"`;
string $player = `button -l "Play" -c "play -forward true"`;
string $stopper= `button -l "Stop" -c "play -state off"`;
string $rewinder = `button -l "Rewind" -c "currentTime 0"`;
string $undoer = `button -l "Undo" -c "undo"`;
//---------------------------------------
string $keyert = `button -l "KEY" -c "setKeyframe"`;

formLayout -edit
-attachForm $trustLv "top" 5
-attachForm $trustLv "left" 0
-attachForm $trustLvSel "top" 5
-attachControl $trustLvSel "left" 5 $trustLv
-attachForm $trustLvKey "top" 5
-attachControl $trustLvKey "left" 5 $trustLvSel
-attachForm $trustRv "top" 5
-attachControl $trustRv "left" 5 $trustLvKey
-attachForm $trustRvSel "top" 5
-attachControl $trustRvSel "left" 5 $trustRv
-attachForm $trustRvKey "top" 5
-attachControl $trustRvKey "left" 5 $trustRvSel
//--------------------------------------------
-attachForm $trustLvB "top" 30
-attachForm $trustLvB "left" 0
-attachForm $trustLvBSel "top" 30
-attachControl $trustLvBSel "left" 5 $trustLvB
-attachForm $trustLvBKey "top" 30
-attachControl $trustLvBKey "left" 5 $trustLvBSel
-attachForm $trustRvB "top" 30
-attachControl $trustRvB "left" 5 $trustLvBKey
-attachForm $trustRv2Sel "top" 30
-attachControl $trustRvBSel "left" 5 $trustRvB
-attachForm $trustRvBKey "top" 30
-attachControl $trustRvBKey "left" 5 $trustRvBSel
//------------------ NEXT group-----------
-attachForm $luikopn "top" 75
-attachForm $luikopn "left" 0
-attachForm $openSel "top" 75
-attachControl $openSel "left" 5 $luikopn
-attachForm $trdown "top" 75
-attachControl $trdown "left" 40 $openSel
-attachForm $trdownSel "top" 75
-attachControl $trdownSel "left" 5 $trdown
//--------------------------------------------
-attachForm $turnLmid "top" 100
-attachForm $turnLmid "left" 0
-attachForm $turnLmidSel "top" 100
-attachControl $turnLmidSel "left" 5 $turnLmid
-attachForm $turnRmid "top" 100
-attachControl $turnRmid "left" 40 $turnLmidSel
-attachForm $turnRmidSel "top" 100
-attachControl $turnRmidSel "left" 5 $turnRmid
//------------------------------------------
-attachForm $schroefLmid "top" 125
-attachForm $schroefLmid "left" 0
-attachForm $schroefLmidSel "top" 125
-attachControl $schroefLmidSel "left" 5 $turnLmid
-attachForm $schroefRmid "top" 125
-attachControl $schroefRmid "left" 40 $schroefLmidSel
-attachForm $schroefRmidSel "top" 125
-attachControl $schroefRmidSel "left" 5 $schroefRmid
//----------------------------------------
-attachForm $trustLacht "top" 170
-attachForm $trustLacht "left" 0
-attachForm $trustLachtSel "top" 170
-attachControl $trustLachtSel "left" 5 $trustLacht
-attachForm $TrustRacht "top" 170
-attachControl $TrustRacht "left" 40 $trustLachtSel
-attachForm $trustRachtSel "top" 170
-attachControl $trustRachtSel "left" 5 $schroefRmid
//------------------------------------------
-attachForm $schroefLacht "top" 195
-attachForm $schroefLacht "left" 0
-attachForm $schroefLachtSel "top" 195
-attachControl $schroefLachtSel "left" 5 $trustLacht
-attachForm $schroefRacht "top" 195
-attachControl $schroefRacht "left" 40 $trustLachtSel
-attachForm $schroefRachtSel "top" 195
-attachControl $schroefRachtSel "left" 5 $schroefRmid
//------------------------------------------
-attachForm $unselect "top" 225
-attachForm $unselect "left" 385
-attachForm $player "top" 225
-attachControl $player "left" 10 $unselect
-attachForm $stopper "top" 225
-attachControl $stopper "left" 10 $player
-attachForm $rewinder "top" 225
-attachControl $rewinder "left" 10 $stopper
-attachForm $undoer "top" 225
-attachControl $undoer "left" 10 $rewinder
//------------------------------------------
-attachForm $keyert "top" 250
-attachPosition $keyert "left" 2 50
$form;
showWindow $test_window;



as some of you may have noticed the select buttons are all wrong.
when i make that button without making it a string it works nicely but when i make it a string they wont select. an example is :
string $turnRmidSel = `button -l "SELECT" -command select Rtrust`;

what is wrong with it?

an other question is this.
i want to make a KEY button on the bottem of the ui. ( its already there )
but i want it the size of the ui. and not the size of the word. how can i do this?

goleafsgo
11-11-2008, 02:19 PM
as some of you may have noticed the select buttons are all wrong.
when i make that button without making it a string it works nicely but when i make it a string they wont select. an example is :
string $turnRmidSel = `button -l "SELECT" -command select Rtrust`;

what is wrong with it?

I think what is happening here is that the -command flag automatically grabs "select" as your command because you didn't explicitly quote the string that you wanted to run. Then it uses "Rtrust" as the name that you want to use for the button. If you had also provided a name at the end, then you'd probably get an error about too many parameters. It should work fine if you just add quotes around "select Rtrust".



an other question is this.
i want to make a KEY button on the bottem of the ui. ( its already there )
but i want it the size of the ui. and not the size of the word. how can i do this?
Do you mean that you want the key button to be as wide as the window? If so, then you should just be able to attach the left/right sides of the button to the form instead of a position which puts it at a percentage of the width.

eg. replace your -attachPosition $keyert line with:

-attachForm $keyert "left" 2
-attachForm $keyert "right" 2

=LuxX=
11-11-2008, 03:46 PM
aaah your a great help!... the select works now.. only i get some other messages when i putted in "" but ill try to find out.. and yes the key has to be as big as the window.i putted that text in the screen.. but cant test it now because i get some wierd warnings al of a sudden.. ill try to fix that, but the first try with select worked.
So thnx allot.. ill update when im done.. cause i have some other small problems ( well not realy problems but i wjust want to know how to do and i hope you can help me a bit with it ;) )

=LuxX=
11-12-2008, 09:39 AM
oki everything is ok now. only i still need to set some sliders.

Ths sliders that went from -20 to 20 i changed to -360 to +360 so its 1 total spin.

Example is :
string $trustLv = `attrFieldSliderGrp -min -360 -max 360 -attribute eerstetruster.rotateZ -l "truster LV"`;

string $trustLvSel = `button -l "SELECT" -command "select eerstetruster"`;

string $trustLvKey = `button -l "POI"`;

now that POI button is the thing i want to make work.
When i select the "eerstetruster" and give a key at 1 with 0 degree and at frame 5 with 180 degree. it will make a animation curve for only rotateZ ( i locked the other atributes)
So that curve i want to make post infiniti ( the POI )

selectKey -add -k -t 0 -t 5 trustvoor3_rotateZ ;

is what i get when i select it, and

setInfinity -poi cycle;

is what i get if i make it post infiniti.
but since my first keys can variate from 0 and 5 i can't totaly use that line.
i gues it must be something like: ( dont laugh :P )

$trustLvKey = selectKey -at trustvoor3_rotateZ setInfinity -poi cycle;

my scripting sucks i know ;) but atleast im trying
but as you could gues this wont work. can any one help me with this? or sugestions

( i actualy want to rotate the propellor with te slider and the furhter i go to the right the faster the propellor turns with infinity but no one seemed to know this cause no one responded to the other topic. so now i gonna try this)

Geuse
01-04-2009, 07:57 AM
Hi everybody.
I'm working on a UI interface for a simple autorigger for a leg, but I'm already stuck. Found a nice thread where I got help setting the base up, but I can't figure out how to copy it for the remaining inputs. I need at least 6 "textFieldsGrp" for specifying all of the legjoints:
Leg, knee1, knee2, ankle, ball, toe. I prefer two joints for the bending of the elbow and knee.

I visualize it working like this: You import or build a simple joint chain and name the joints to your preference. Then you execute the autorigger where you specify and load (or write) each joint in the appropriate field. At last you simply hit a button called "setupLeg" and it will do the rest for you.

But as said, I'm stuck and would really appreciate any advice on how to proceed.




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


window -t "autorig v.1.0" -wh 100 100 SetupLegUI;


rowLayout -adj 1;

string $controllerNameTextField;
string $controllerNameButtonCommand[] = `ls -sl`;
string $replacement = $controllerNameButtonCommand[0];

$controllerNameTextField = `textFieldButtonGrp -label "Specify Leg Joint" -text $replacement -buttonLabel "set"`;

string $cmd = "string $sel[] = `ls -sl`;";
$cmd += "if (size($sel))";
$cmd += " textFieldButtonGrp -e -text $sel[0] " + $controllerNameTextField +";";

textFieldButtonGrp -adj 2 -edit -buttonCommand $cmd $controllerNameTextField;

setParent..;


window -edit -wh 420 300 -topLeftCorner 200 1150

SetupLegUI;
showWindow;

Geuse
01-04-2009, 01:49 PM
Hm...I managed to solve it by simply changing the layout type to "columnLayout" instead of "rowLayout". Why is that? Anybody?

Mikademius
01-26-2009, 01:49 PM
Hi guys.
Quick Question...

Is it possible to make a window run a command, say "sphere" , when you click the "X" to kill it?
You can run on minimize and restore, but I haven't seen any flag for exiting. Is it possible?

ewerybody
01-26-2009, 02:05 PM
Is it possible to make a window run a command, say "sphere" , when you click the "X" to kill it?
You can run on minimize and restore, but I haven't seen any flag for exiting. Is it possible?yes it is: http://download.autodesk.com/us/maya/2008help/Commands/scriptJob.html#flaguiDeleted

Mikademius
01-26-2009, 02:40 PM
Yeah, I thought of that ;) But I was thinking without introducing the scriptJob. Sorry, I should have made that clear in the last post...

cakesson
03-12-2009, 07:55 PM
If you have a float field group that consists of more than one float field, how can you know which value has been changed if you pass it to another procedure? There is only one change command. I've tried finding information on querying which of the fields are in focus but haven't been able to find anything.

Any ideas?

Thanks,
/Christian

Geuse
04-26-2009, 02:56 PM
Hi I'm playing around with colors in the UI and So I've created a variable to hold a blue color so I don't have to type this in every field manually and if I want to change it I could just change it in the variable declaration.
string $bgc = "-bgc 0.4 0.7 1";


the problem is when adding this to a rowLayout like so

//ROWLAYOUT START
rowLayout $bgc
-numberOfColumns 3
-columnWidth3 120 120 120;


it does not work and I can tell I'm doing something very wrong, I just can't figure out how to write it correctly.

RavenEye
04-26-2009, 03:19 PM
Hey Geuse,

The problem is that you are declaring a string variable. If you want to change the -bgc you are going to need a float variable for ea. rgb or a float array. I hope this helps out.

Geuse
04-26-2009, 04:00 PM
Thanks for the prompt reply!
I thought you could just replace the command with the a string variable and it would be read like so when executed.


what is e.a short for?

thanks!

Geuse
04-26-2009, 04:10 PM
I have another question I'd like to share with all of you.

I'm trying to design a layout, but I'm unsure of wich layout types I need combined to pull this off(it's been edited in photoshop), if it's even possible. But, really there is no real use for this other than the fact that it just looks sweet and clean =). I just want to master UI creation as best as I can.


http://forums.cgsociety.org/attachment.php?attachmentid=141493&stc=1

http://forums.cgsociety.org/attachment.php?attachmentid=141494&stc=1

http://forums.cgsociety.org/attachment.php?attachmentid=141495&stc=1

RavenEye
04-26-2009, 05:32 PM
ea. means each.

For what you did in photoshop, it is best to us a columnLayout. Your design is a pretty simple straight down design.

Geuse
04-26-2009, 07:04 PM
Ah, thanks alot for clarifying.
Can you attach a button in a columnLayout to the far down edge?
I thought you needed a formLayout to do that.
Then I've been struggeling with the -adjustment flag to find a way to make the checkboxes and radiobuttons stretch to fit the window, but haven't found a value that would allow it. About the textFieldButtonGrp command. Which flag is used to place it to fit the window from top to bottom with all the textfields laid out evenly.

Geuse
04-27-2009, 04:50 PM
I'm sorry for cluttering up this fine thread, but I'm stuck. After several and several tries and playing around with different layouts I still can't get it to act as i'd like.
Tried the formlayout and this works more like i intended as you can attach layouts to each other, but I don't understand how you're able to make button 1, 2 and 3 space out evenly between "Hi" and "Goodbye"

if (`window -ex layoutWin`)
deleteUI layoutWin;
window -widthHeight 300 205 layoutWin;
string $form = `formLayout -numberOfDivisions 100`;

string $top = `columnLayout -adj true`;
button -h 40 -l Hi ;

setParent..;
string $mid = `columnLayout -adj 1`;
button -l 1;
button -l 2;
button -l 3;

setParent..;
string $bottom = `columnLayout -adj true`;
button -h 40 -l "Good Bye" -al center ;

setParent..;


formLayout -edit

-attachForm $top "top" 5
-attachForm $top "left" 5
-attachForm $top "right" 5
-attachNone $top "bottom"


-attachControl $mid "top" 5 $top
-attachForm $mid "left" 5
-attachForm $mid "right" 5
-attachControl $mid "bottom" 5 $bottom


-attachNone $bottom "top"
-attachForm $bottom "left" 5
-attachForm $bottom "right" 5
-attachForm $bottom "bottom" 5




$form;

showWindow layoutWin;


Anyone, could really, really use some help. Thanks.

fritz8th
05-01-2009, 04:27 PM
Hey Geuse the first thing you can add is the -rs (rowSpacing) flag to the $mid columnLayout to help space out your buttons 1 ,2, and 3. I added the windowPref at the top under the delete ui check it just helps me to keep my windows consistent in there size. other than that I just played with the window height value and the attach for the $bottom button to get it spaced out to look even. Here is the code I tweaked. Hope this helps out.


if (`window -ex layoutWin`)
deleteUI layoutWin;
if( `windowPref -exists layoutWin` )
windowPref -r layoutWin;
window -w 300 -h 225 layoutWin;
string $form = `formLayout -numberOfDivisions 100`;

string $top = `columnLayout -adj true`;
button -h 40 -l Hi ;

setParent..;
string $mid = `columnLayout -rs 5 -adj 1`;

button -l 1;

button -l 2;

button -l 3;


setParent..;
string $bottom = `columnLayout -adj true`;
button -h 40 -l "Good Bye" -al center ;

setParent..;


formLayout -edit

-attachForm $top "top" 5
-attachForm $top "left" 5
-attachForm $top "right" 5
-attachNone $top "bottom"


-attachControl $mid "top" 5 $top
-attachForm $mid "left" 5
-attachForm $mid "right" 5
-attachControl $mid "bottom" 5 $bottom


-attachControl $bottom "top" 97 $top
-attachForm $bottom "left" 5
-attachForm $bottom "right" 5
-attachControl $bottom "bottom" 0 $bottom




$form;

showWindow layoutWin;

Geuse
05-01-2009, 04:42 PM
Thanks alot. However the "goodbye" button disappears when expanding the window.
I don't have time right now to check the code, need to eat before going to see Wolverine in 50 mins. Also I was interested in spacing them out dynamically as you drag according to the height of the window.

Thanks for the effort, I appreciate it.

praburaj
06-05-2009, 08:57 AM
Hi all,

Is there any possibility of having text mask or password mask on textField using mel... or any alternative way to do that in Maya... may be using python also no problem

ewerybody
06-05-2009, 12:07 PM
Hello

You could use a scrollField.
Get the last entered letter from it via keyPressedCommand. Save it somehow else and replace the text with * on each keystroke... Unfortunately there is no possibility using Mayas UI stuff this way. Not even with python because it would use the same controls.

but scrollField is somehow bitchy: If you ask the scrollfield for its text on keypressed command it sometimes returns the content from before the key was pressed. You could circumvent this with evalDeffered (evalDeffered("scrollField -q -text myScrollfield"))..

But if you include QT with a python plugin you surely have such possibilities!

=LuxX=
07-27-2009, 01:55 PM
hi all,

I m trying to learn MEL but its hard.. because i dont have any one to ask when i got problems and the book i have isnt helpfull either.

but i got this code and now i want that :
string $liftCraneAngle = `floatFieldGrp -l "Crane angle" -attribute Aframe_rotate.rotateY`;

part to work. i probably wrote it all wrong but dont know how to do it.

i want to fill in my rotateY and then it has to rotate, i tryed allot but with 0 result.

with my slider group the code like this worked but i dont want a slider.
can any one help me out?




if ( `window -exists MyWindow` )
{ deleteUI MyWindow; }
window -t "controls" MyWindow;



string $Mhook = "MainhookCluster";
string $Auxy1 = "Aux1Cluster";
string $WhipBlock = "WhipCluster";
string $Auxy2 = "Aux2Cluster";

columnLayout -adj true;
optionMenu -label "Hooks" -changeCommand "-select #1";

menuItem -label "Main";
menuItem -label "Aux_1";
menuItem -label "Aux_2";
menuItem -label "whip_block";

setParent ..;


rowLayout -nc 2 -adj true;
text -l Lift; text -l Setdown;
setParent ..;

rowLayout -nc 5 -adj true;
string $liftCraneAngle = `floatFieldGrp -l "Crane angle" -attribute Aframe_rotate.rotateY`;

$setCraneAngle = `floatFieldGrp -l "Crane angle"`;
setParent ..;

rowLayout -nc 5 -adj true;
floatFieldGrp -label "Boom angle" -value1 0.0;
floatFieldGrp -label "Boom angle" -value1 0.0;

setParent ..;

button -l OK;
button -l cancel;

showWindow;



[/CODE]

SubashGershome
08-08-2009, 08:52 AM
How do I edit the inputs of a node through scripting???....For example, i tried editing the curvature of Bend node(non linear transformation), but doesnt work...Can anybody help Me?????

ckas
08-21-2009, 10:42 AM
Hi there, I´m pretty new to UI scripting. I want tree buttons in a row that resize equally like the "blabla"-Apply-Cancel buttons in the standard tools. What layout should I take then? As I understood the rowlayout only resizes one element...so I probably would need a formlayout?

thanks a lot

ewerybody
08-21-2009, 10:55 AM
thats right. you'd have to utilize the -ap or attachPosition flag for this:

window;
formLayout myForm;
button myButton1;
button myButton2;
button myButton3;
formLayout -edit
-af myButton1 left 0
-ap myButton1 right 0 33
-ap myButton2 left 0 33
-ap myButton2 right 0 67
-ap myButton3 left 0 67
-af myButton3 right 0
-af myButton1 bottom 0
-af myButton2 bottom 0
-af myButton3 bottom 0
myForm;
showWindow;

ckas
08-21-2009, 11:07 AM
I also have another question. I need checkboxes which are only active when activating another checkbox. I got it to work with a few if-elses now, but I now tried to pack all these dependend checkboxes in a frame layout to deactivate/activate my whole frame. Problem is, that this frame isn´t grey when deaktivated, like my checkboxes are (when nonactive).
Are there differences in the active/inactive feature between whole layouts and controls?

cheers

=LuxX=
08-31-2009, 01:22 PM
Hi all,
im strugling with rather somthing simple I think.
Im trying to setup a proc so i can change a value in my own UI and then it updates the object.
but i get stuck all the time, could some one point me in the good derction?
//----- sliders is where it starts

( I want to change the Aframe_rotate.rotateY )



showWindow;

if ( `window -exists MyWindow` )

{ deleteUI MyWindow; }

window -t "controls" MyWindow;



string $form = `formLayout -numberOfDivisions 1000`;



string $Mhook = "MainhookCluster";

string $Auxy1 = "Aux1Cluster";

string $WhipBlock = "WhipCluster";

string $Auxy2 = "Aux2Cluster";



//--- MENU---

string $menutje = `optionMenu -label "Hooks" -changeCommand "-select #1"`;

menuItem -label "Mhook";

menuItem -label "Aux_1";

menuItem -label "Aux_2";

menuItem -label "whip_block";



//--- SLIDERS---

global proc setvalue(){

float $entervalue = ` value Aframe_rotate.rotateY`;

}

string $liftCraneAngle = `floatFieldGrp -l Crane_Angle -cc "setvalue"`;

string $liftBoomAngle = `attrFieldSliderGrp -min -5 -max 78.68 -attribute Boom_controler.BOOM -l "Boom angle"`;



//----- BUTTONS------



string $keyer = `button -l "Set point" -c setKeyframe`;

string $player = `button -l "PLAYBLAST" -c playblast`;

string $cancel = `button -l cancel`;

string $undoer = `button -l "Undo" -c "undo"`;



string $vieuwScreen = `modelEditor -displayAppearance smoothShaded -dtx on -gr off -alo off -pm on`;



//---- FORMLAYOUT---



formLayout -edit



-attachForm $menutje "top" 5



-attachForm $liftCraneAngle "top" 70

-attachForm $liftCraneAngle "left" 70



-attachForm $liftBoomAngle "top" 100

-attachForm $liftBoomAngle "left" -70



-attachForm $keyer "top" 150

-attachForm $keyer "left" 140



-attachForm $undoer "top" 150

-attachForm $undoer "left" 180



-attachForm $player "top" 150

-attachForm $player "left" 450



-attachForm $cancel "top" 150

-attachForm $cancel "left" 530



-attachForm $vieuwScreen "top" 250



$form;



showWindow;

Geuse
11-11-2009, 05:43 PM
I want 6 radioButtons in a 2 columnlayout like the image, but seems LabelArray can only hold a maximum of 4 values. =/

ewerybody
11-12-2009, 09:48 AM
have a look at the radioCollection (http://download.autodesk.com/us/maya/2009help/Commands/radioCollection.html)-docs. you can have as many radioButtons in the collection as you like! And you can exchange the columnLayout with any layout you like. As formLayout for instance!

btw: from the images I'm not getting where you're approaching to ;]

Geuse
11-13-2009, 01:19 AM
Ah thanks, will look into that.
It's actually supposed to be an autorigger for a leg. So because you are free to use your preferred orientation of joints I need to know in what axis the control groups for the foot's ik handle should rotate in for the roll attribute to work as expected. ;)

I'm really into setting the orientation myself and testing simple smooth bind with fk rotations before setting it up.
So the script will work like this:

First select a joint in the chain and press the button. It will rename the whole chain and create, scale and place out controls for the leg. Both ik and fk. Then it will prompt you with an additional window.
Before you continue the setup you are free to scale and move the controls as you please. When you're happy you press the button in the newly created window "continue setup".

Your joint chainvand control curves will copy, mirror and rename themselves correctly. When all this is done the real setup procedure takes over and creates the rig for both L and R side based on the names which has been given the controls and joint chains prior. I want something easy but with a bit of custom alternatives. For instance if you need the jointchain orientation to point in the z direction and for instance have x as the twisting axis it will still work without having to modify the code. Also, especially controls, I often want to scale or perhaps change for other autoriggers and I'm not really allowed to do that in an easy way. So I end up scaling the cv:s after the rig has been created, but I want simplicity and control and this way I can have the left and right footCtrls exactly the same size without to much fuzz. Yippie =).

I'm sorry I went off topic just wanted to share my ideas and then I ran off.


Thanks again.

beetz15s
12-26-2009, 07:04 AM
I'm making a ui in PYTHON that will have sections generated and removed by the user. What are some ways to generate and remove rows in a UI?

ewerybody
12-29-2009, 01:18 AM
If you have rows the columnLayout is probably the most simple way to arrange your lines.

You can just deleteUI the desired elements from it and it rearranges. If you create new elements parented under the columnLayout they will be put last.

example:
// create a window with columnLayout and controls:
window;
columnLayout testColumnLayout;
checkBox -label 1 testcheckBox1;
checkBox -label 2 testcheckBox2;
checkBox -label 3 testcheckBox3;
showWindow;

// remove a control:
deleteUI testcheckBox2;

// create new control:
checkBox -label 4 -parent "testColumnLayout" testcheckBox4;

jalixko
12-29-2009, 11:40 PM
Hi all!
I am newbe on mel. This is simple i would like to tear off a window panel with a camera in the scene, it is a camera for the face of a character, any idea? Thanks

Buexe
12-30-2009, 03:49 PM
Hi all!
I am newbe on mel. This is simple i would like to tear off a window panel with a camera in the scene, it is a camera for the face of a character, any idea? Thanks

Have you tried the modelEditor command? I think it does what you are looking for. Check the docs for details

beetz15s
01-01-2010, 04:29 AM
the problem is there will be a undeclared number of rows. The user will generate new ones by clicking a button. i have discovered i must use a class to create instances and some form of array iterator to create unique names for each asset. row[i].

Buexe
01-01-2010, 04:56 PM
the problem is there will be a undeclared number of rows. The user will generate new ones by clicking a button. i have discovered i must use a class to create instances and some form of array iterator to create unique names for each asset. row[i].

collect the names in a global array variable or one that is unique within your class. Then you can access them for refreshing deleting, adding etc.

Moreto
01-29-2010, 10:23 PM
I'm trying to code a simple UI to use to re-orient joins so they behave properly as a FK chain. It consists of three sliders (X Y Z), however I can't get it to apply the changes to the joint and it is unable to tell that I have anything selected, being knew at coding mel I'm quite stumped as to where I should go now, and any help would be appreciated.
global proc rotateJoint ()
{
//Checks to see if the window already exists, if it does it closes it

if (`window -q -ex RJwindow`) deleteUI RJwindow;

window
-title "Joint Reorient"
RJwindow;

//Command used to add a layout to the window
columnLayout;
//The 'text' command prints text into your UI

floatSliderGrp -label "X" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0;

floatSliderGrp -label "Y" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0;

floatSliderGrp -label "Z" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0
-cc "Zvalue";




//Command line to create the window


showWindow RJwindow;
}

global proc Zvalue ()
{
float $Slider = `floatSliderGrp -q -v`;
string $zstring =`ls -sl`;
setAttr $zstring.rotateZ $Slider;
}

RavenEye
01-30-2010, 12:45 AM
global proc rotateJoint ()
{
//Checks to see if the window already exists, if it does it closes it

if (`window -q -ex RJwindow`) deleteUI RJwindow;

window
-title "Joint Reorient"
RJwindow;

//Command used to add a layout to the window
columnLayout (Give you column a name) mainCL;
//The 'text' command prints text into your UI

floatSliderGrp -label "X" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0 (Give you slider a name)xFSG;

floatSliderGrp -label "Y" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0 (Give you slider a name)yFSG;

floatSliderGrp -label "Z" -field true
-minValue -360.0 -maxValue 360.0
-fieldMinValue -360.0 -fieldMaxValue 360.0
-value 0
-cc "Zvalue" (Give you slider a name)zFSG;

//Command line to create the window


showWindow RJwindow;
}

global proc Zvalue ()
{
float $Slider = `floatSliderGrp -q -v (Give you slider a name) zFSG`;
string $zstring[] =`ls -sl`; // You need to make this item into an array. Any time that you have a list in a variable. It has to be in an array
setAttr ($zstring[0] + ".rotateZ") $Slider;
}

Exo7
05-03-2010, 01:56 PM
Hi, I have a question about deferring the change command for checkboxes.

I am working on an UI project (pretty advanced at this point) wich was keeping crashing Maya randomly when the -cc flag was triggered on a checkbox (banghead and stuff). I seem to finally have found a fix by using the evalDeferred command on top. It's the first time I'm finding a use for deferred code.

Why is it, that when the same change command is used on an other control type no crash happen, while it was NOT deferred ?

What can you said about UI drawing and deferred code (callbacks specially) ?

Thanks

NaughtyNathan
05-03-2010, 02:24 PM
no idea Adam. without seeing your -cc code it could be any number of things. I'd suggest submitting it as a bug to Autodesk though if the same code crashes checkBox but not other control types.

:nathaN

goleafsgo
05-03-2010, 03:05 PM
Are you changing the UI at all in your changeCommand callback? The usual problem, and the one that evalDeferred is usually used to get around, is when you want to create/delete UI in the callback. So you end up deleting the UI control that is currently calling your code and when you're done it will crash if it tries to do anything.

Exo7
05-03-2010, 10:56 PM
Yes goleafsgo, the change command is calling a procedure wich will return a list of concatenated strings (often through supplementary embedded procedures), list wich is then sent to an interpreter procedure wich will destroy and rebuild the same window based on the concatenated information. These concatenated strings often contain raw UI code to be evaluated after the window was recreated, when they are not simply designed to feed automatic controls creation with attributes and labels (see dead excerpt below, not relevant to the current issue). Pretty much the case you are mentioning I suspect, the control is causing its own destruction with the window hosting it. Should I defer every control -cc's code triggering this redraw mechanism ? Is it even safer the defer the raw UI code to be evaluated ? Simply put, why use eval() in place of evalDeferred() for UI controls, if the question makes sense ?

I read somewhere that slow UI creation could end after Maya started on the next execution steps, in other words, drawing an UI can take longer than Maya is expecting (question mark). If that's true then I for one am finding that this important information is underexposed to beginners, it costed me about one year and the related nerves to put a finger on this, deferring code is not natural to noobs :)

I am guessing that the problem comes with the unhandled error (crash), therefore the issue should be exposed better.

- - - -

All in all, this first UI project of mine was very experimental (read: from an unexperimented coder, still unsure on how dynamic UI should be done) and that's why, Nathan, I didn't send a bug report to Autodesk: my code had to be faulty. You would not believe what I fed the -cc flag with, looking for a work around when I found that using -cc with enum was executing the code (the very last line was my concern) while the attribute itself remained unchanged... well, I used scriptJobs then (not anymore) but that never fixed the crash. I have put ANYTHING in the -cc flag of enums for one year

/*
DISCLAIMER:
DO NOT USE, COUNTER-EXAMPLE !!!

eg: the received string (among a list,
created by 'EDI_list()' below) would be:

"enum¤label¤node¤attribute"

tokenized using "¤" in $args[], gives

$args[0] >> enum
$args[1] >> label
$args[2] >> node
$args[3] >> attribute

Then comes the -cc flag for this very enum control,
referencing to self
(the '#1' callback returns a string for enums argh,
I had to feed in the name of possible attributes
passing there):
*/

"-cc ( "string $sEnum0[]={"
+ "\"Gaussian\",\"ior\",\"Linear\",\"None\","
+ "\"blackbody\",\"Diffuse\",\"Basic\","
+ "\"Circular\",\"Uniform\"}; "//,\"Camera\"
+ "string $sEnum1[]={"
+ "\"Box\","
+ "\"specular reflectivity\",\"Reinhard\","
+ "\"PhysicalSunSky\",\"uniform\",\"Phong\","
+ "\"Dermis\",\"Generated\",\"Henyey-Greenstein\"}; "//,\"Tonemapping\"
+ "string $sEnum2[]={"
+ "\"MN_Cubic\",\"nkData\",\"Camera\","
+ "\"BackgroundColour\",\"peak\","
+ "\"Oren-Nayar\",\"Epidermis\",\"Image\"};"
+ "string $sEnum3[]={\"LatLong\",\"Specular\"};"
+ "string $sEnum4[]={\"Spherical\",\"Glossy Transparent\"};"
+ "string $sEnum5[]={\"Null\",\"Renderer\"}; "
+ "if(`stringArrayContains \"#1\" $sEnum0`)"
+ "setAttr "+$args[2]+"."+$args[3]+" 0; "
+ "else if(`stringArrayContains \"#1\" $sEnum1`)"
+ "setAttr "+$args[2] + "." + $args[3]+" 1; "
+ "else if(`stringArrayContains \"#1\" $sEnum2`)"
+ "setAttr "+$args[2] + "." + $args[3]+" 2; "
+ "else if(`stringArrayContains \"#1\" $sEnum3`)"
+ "setAttr "+$args[2]+"."+$args[3]+" 3; "
+ "else if(`stringArrayContains \"#1\" $sEnum4`)"
+ "setAttr "+$args[2]+"."+$args[3]+" 4; "
+ "else if(`stringArrayContains \"#1\" $sEnum5`)"
+ "setAttr "+$args[2]+"."+$args[3]+" 5; "
+

/*
command of the year: evalDeferred
*/

"evalDeferred(\"EDI_list "+$target+" 0\");"
)

laughs. This is dead code, as you can see at this point I was forced to overcome a control functionality drop. The eval (now deferred) was executed but the attribute wasn't changing with the control anymore. ? Fixed anyway, can not reproduce... pipe was probably broken. Feel free to comment.

Got similar UI caveheats to depict ? I'm getting too old to wait one year a crash :arteest: need white marks from your experience, to all.

Thanks already !

PS: multiple edits, I'm done now