I am trying to make a window with 2 buttons that you can click that either gives you a car or a bike, then you input a start frame and an end frame of how long you want your animation to be, but i need a way to communicate what the user inputs as a start frame and as an end frame so that there are keyframes in place and the car/bike is moving forward until the specified end frame.
MEL - Maya UI Building
Hi all Im trying to make a second tab in my script but i keep getting the error:
[size=1]ModelEdMenu modelEditor1;
// Error: line 225: Object is not a child: MyWindow|tabLayout //
[/size]
now the funny thing is … line 225 is empty
on line 226 there is [size=1]
$tabEen;
ill past my script here… ( i left all the unimportand stuff out so this wont be to long to read)
if some one knows where i did something wrong… please help
[/size]
if ( `window -exists MyWindow` )
{ deleteUI MyWindow; }
window -s 0 -t "controls" MyWindow;
string $tabs = `tabLayout -innerMarginWidth 0 -innerMarginHeight 0 tabLayout"`;
string $tabEen= `formLayout -numberOfDivisions 100 "settings"`;
/////////////////////////////////
/////////////////////////////////VIEUWS
string $vieuwScreen = `modelEditor -displayAppearance smoothShaded -cam front -dtx on -gr off -alo on -nc off -pm on`;
string $camsettings = `text "CAMERA settings"`;
string $wireshade =`button -label "Wireframe"
-command ("modelEditor -edit -displayAppearance wireframe " + $vieuwScreen)`;
string $Flatshade = `button -label "Flat Shaded"
-command ("modelEditor -edit -displayAppearance smoothShaded " + $vieuwScreen)`;
radioCollection;
string $persCam = `radioButton -label "Perspective"
-cc ("modelEditor -edit -cam persp " + $vieuwScreen)`;
string $frontCam = `radioButton -label "Side"
-cc ("modelEditor -edit -cam front " + $vieuwScreen)`;
string $topCam = `radioButton -label "Top"
-cc ("modelEditor -edit -cam top " + $vieuwScreen)`;
string $sideCam = `radioButton -label "Front"
-cc ("modelEditor -edit -cam side " + $vieuwScreen)`;
string $BackCam = `radioButton -label "Back"
-cc ("modelEditor -edit -cam Back " + $vieuwScreen)`;
string $ImgLogoBottom = `image -image "S:/Ani Program/BMP/LogoBottem.bmp" -w 1700 -h 50`;
setParent..;
/////////////////////////////////
/////////////////////////////////TAB 2
string $tabTwee = `formLayout "Movement"`;
string $ImgTurnDown = `image -image "S:/Ani Program/BMP/turnDownArrow.bmp" -w 80 -h 50`;
setParent..;
/////////////////////////////////
///////////////////////////////// FORMLAYOUT
formLayout -edit
here i have the complete form stuff of tab 1
$tabEen;
////////////////////////////////////
////////////////////////////////////TAB2
formLayout -edit
-af $ImgTurnDown "top" 500
-af $ImgTurnDown "left" 200
$tabTwee;
tabLayout -edit -tabLabel $tabEen "Settings" -tabLabel $tabTwee "Movement"
$tabs;
showWindow;
Hey LuxX, always make sure you don’t just look at the LAST error message Maya returns as it may simply be due to an earlier error. The code you posted has a syntax error on line 6 (a " at the end of the line that shouldn’t be there).
string $tabs = tabLayout -innerMarginWidth 0 -innerMarginHeight 0 tabLayout"
;
If you remove and fix this and re-run it it all works fine.
:nathaN
Thnx mate for your response… but that is not the problem. when i change it i still get an error.
// Error: line 230: Object is not a child: MyWindow|tabLayout //
I tryed to learn this from a other script someone wrote but he has:
[size=1]string $tabs = tabLayout -innerMarginWidth 0 -innerMarginHeight 0 "tabLayout"
;
with the " "?
well for today i’ve had it… tomorrow i’ll have a fresh look at it
thnx again tho
[/size]
well it works fine for me, so the error must be in the bits of code you didn’t post…?
:nathaN
This is my full code… ( without the procs they are writen global) or could it be that 1 of those procs is wrong ( they do work )
ive read this over and over but cant find any missing ; " () or what ever…
/////////////////////////////////
/////////////////////////////////WINDOW / TAB 1
if ( `window -exists MyWindow` )
{ deleteUI MyWindow; }
window -s 0 -t "controls" MyWindow;
string $tabs = `tabLayout -innerMarginWidth 0 -innerMarginHeight 0 "tabLayout"`;
string $tabEen= `formLayout "settings"`;
/////////////////////////////////
/////////////////////////////////CHECK IF BOAT IS THERE, IF NOT IT WILL BE IMPORTED
importproc;
/////////////////////////////////
/////////////////////////////////IMPORT MODULES THIS CAN BE TOPSIDES JACKETS OR ANYTHING ELSE.
string $impModule = `button -l "Import Module" -c ImportingModule`;
/////////////////////////////////
/////////////////////////////////IMPORT SEABED THIS GIVES YOU THE OPPERTUNITY TO PUT A SEABED IN YOUR SCENE
string $impSeabed = `button -l "Import Seabed" -c importSeabed`;
/////////////////////////////////
/////////////////////////////////IMPORT OCEAN GIVE YOU THE OPERTUNITY TO IMPORT OCEANS THERE ARE DIFFERENT OCEANS FOR DIFFERENT LOCATIONS
string $impOcean = `button -l "Import Ocean" -c importOcean`;
/////////////////////////////////
/////////////////////////////////SET HEIGHT OF THE WATERLEVEL
string $OceanHeight =`floatFieldGrp -l "Ocean height" -cc "OceanHeightProc()" -extraLabel "m"`;
/////////////////////////////////
/////////////////////////////////SET THE HEIGHT OF THE SEABED
string $SeabedHeight= `floatFieldGrp -label "Seabed height" -cc "SeabedHeightProc()" -extraLabel "m"`;
/////////////////////////////////
/////////////////////////////////HOOKS
string $menutje = `optionMenu -label "Hooks" -changeCommand "-select #1"`;
menuItem -label "Mhook";
menuItem -label "Aux_1";
menuItem -label "Aux_2";
menuItem -label "Lip_block";
/////////////////////////////////
/////////////////////////////////CRANE LIFT
string $craneAngleLtext = `text -l "Crane angle"`;
string $BoomAngleLtext = `text -l "Boom angle"`;
string $craneLifttext = `text -l "Lift"`;
string $floatFieldLiftCrane = `floatField -minValue -360 -maxValue 360 -cc " floatLiftCrane()"`;
/////////////////////////////////
/////////////////////////////////BOOM LIFT
string $floatFieldLiftBoom = `floatField -minValue -5 -maxValue 78.68 -cc "floatLiftBoom()"`;
/////////////////////////////////
/////////////////////////////////ANIMATION TIME
float $sliderValue[];
string $tijdField = `floatFieldGrp -l "Animation time in sec"
-cc "currentTime (#1 + \"sec\");playbackOptions -edit -max (#1 + \"sec\");"` ;
/////////////////////////////////
/////////////////////////////////CRANE SET
string $craneSettext = `text -l "Set"`;
string $floatFieldSetCrane = `floatField -minValue -360 -maxValue 360 -cc " floatSetCrane()"`;
/////////////////////////////////
/////////////////////////////////BOOM SET
string $floatFieldSetBoom = `floatField -minValue -5 -maxValue 78.68 -cc "floatSetBoom()"`;
/////////////////////////////////
/////////////////////////////////BUTTONS
string $playMov = `button - l "PLAY/STOP" -c "playButtonForward"`;
string $rewMov = `button -l "REWIND" -c "playButtonStart"`;
string $player = `button -l "Create movie" -c "performPlayblast 3"`;
string $cancel = `button -l "cancel" -c -cl `;
string $undoer = `button -l "Undo" -c Undo `;
/////////////////////////////////
/////////////////////////////////VIEUWS
string $vieuwScreen = `modelEditor -displayAppearance smoothShaded -cam front -dtx on -gr off -alo on -nc off -pm on`;
string $camsettings = `text "CAMERA settings"`;
string $wireshade =`button -label "Wireframe"
-command ("modelEditor -edit -displayAppearance wireframe " + $vieuwScreen)`;
string $Flatshade = `button -label "Flat Shaded"
-command ("modelEditor -edit -displayAppearance smoothShaded" +$vieuwScreen)`;
radioCollection;
string $persCam = `radioButton -label "Perspective"
-cc ("modelEditor -edit -cam persp " + $vieuwScreen)`;
string $frontCam = `radioButton -label "Side"
-cc ("modelEditor -edit -cam front " + $vieuwScreen)`;
string $topCam = `radioButton -label "Top"
-cc ("modelEditor -edit -cam top " + $vieuwScreen)`;
string $sideCam = `radioButton -label "Front"
-cc ("modelEditor -edit -cam side " + $vieuwScreen)`;
string $BackCam = `radioButton -label "Back"
-cc ("modelEditor -edit -cam Back " + $vieuwScreen)`;
string $ImgLogoBottom = `image -image "S:/Ani Program/BMP/LogoBottem.bmp" -w 1700 -h 50`;
setParent..;
/////////////////////////////////
/////////////////////////////////TAB 2
string $tabTwee = `formLayout "Movement"`;
string $ImgTurnDown = `image -image "S:/Ani Program/BMP/turnDownArrow.bmp" -w 80 -h 50`;
string $ImgTurnUp = `image -image "S:/Ani Program/BMP/turnDownArrow.bmp" -w 80 -h 50`;
string $ImgArrowleft = `image -image "S:/Ani Program/BMP/Left_arrow.bmp" -w 50 -h 50`;
string $ImgArrowRight = `image -image "S:/Ani Program/BMP/right_arrow.bmp" -w 50 -h 50`;
string $ImgArrowUp = `image -image "S:/Ani Program/BMP/up_arrow.bmp" -w 50 -h 50`;
string $ImgArrowDown = `image -image "S:/Ani Program/BMP/Down_arrow.bmp" -w 50 -h 50`;
setParent..;
/////////////////////////////////
///////////////////////////////// FORMLAYOUT
formLayout -edit
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
-attachForm $craneAngleLtext "top" 55
-attachForm $craneAngleLtext "left" 50
-attachForm $BoomAngleLtext "top" 85
-attachForm $BoomAngleLtext "left" 50
-attachForm $floatFieldLiftCrane "top" 50
-attachForm $floatFieldLiftCrane "left" 110
-attachForm $floatFieldLiftBoom "top" 80
-attachForm $floatFieldLiftBoom "left" 110
-attachForm $craneLifttext "top" 35
-attachForm $craneLifttext "left" 130
-attachForm $craneSettext "top" 35
-attachForm $craneSettext "left" 200
-attachForm $floatFieldSetCrane "top" 50
-attachForm $floatFieldSetCrane "left" 180
-attachForm $floatFieldSetBoom "top" 80
-attachForm $floatFieldSetBoom "left" 180
-af $tijdField "top" 10
-af $tijdField "left" 20
-attachForm $playMov "bottom" 50
-attachForm $playMov "right" 90
-attachForm $rewMov "bottom" 50
-attachForm $rewMov "right" 30
-attachForm $undoer "bottom" 50
-attachForm $undoer "right" 170
-attachForm $player "bottom" 100
-attachForm $player "right" 90
-attachForm $cancel "bottom" 100
-attachForm $cancel "right" 30
-attachForm $camsettings "top" 200
-attachForm $camsettings "left" 5
-attachForm $vieuwScreen "top" 110
-attachForm $vieuwScreen "left" 110
-attachForm $vieuwScreen "bottom" 110
-attachForm $vieuwScreen "right" 310
-attachForm $wireshade "top" 360
-attachForm $wireshade "left" 5
-attachForm $Flatshade "top" 390
-attachForm $Flatshade "left" 5
-attachForm $persCam "top" 220
-attachForm $persCam "left" 5
-attachForm $topCam "top" 240
-attachForm $topCam "left" 5
-attachForm $frontCam "top" 260
-attachForm $frontCam "left" 5
-attachForm $sideCam "top" 280
-attachForm $sideCam "left" 5
-attachForm $BackCam "top" 300
-attachForm $BackCam "left" 5
-attachForm $impModule "top" 80
-attachForm $impModule "left" 1610
-af $OceanHeight "top" 140
-af $OceanHeight "right" 0
-attachForm $impOcean "top" 140
-attachForm $impOcean "left" 1610
-af $SeabedHeight "top" 110
-af $SeabedHeight "right" 0
-attachForm $impSeabed "top" 110
-attachForm $impSeabed "left" 1610
-attachForm $menutje "top" 80
-attachForm $menutje "right" 50
-af $ImgLogoBottom "bottom" 30
-af $ImgLogoBottom "left" 0
$tabEen;
////////////////////////////////////
////////////////////////////////////TAB2
formLayout -edit
-af $ImgTurnDown "top" 200
-af $ImgTurnDown "left" 500
-af $ImgTurnUp "top" 700
-af $ImgTurnUp "left" 700
-af $ImgArrowleft "top" 450
-af $ImgArrowleft "left" 250
-af $ImgArrowRight "top" 450
-af $ImgArrowRight "right" 250
-af $ImgArrowUp "top" 200
-af $ImgArrowUp "left" 500
-af $ImgArrowDown "bottom" 200
-af $ImgArrowDown "left" 500
$tabTwee;
tabLayout -edit
-tabLabel $tabEen "Settings"
-tabLabel $tabTwee "Movement"
$tabs;
showWindow;
LuxX, the error is in your formLayout.
You’ve created a top level tabLayout called $tabs, then you created two children of this tabLayout, formLayouts: $tabEen and $tabTwee.
Your error is that you have tried to layout $tabs inside the formLayout $tabEen. This is clearly invalid as the tabLayout $tabs is the parent of $tabEen.
You need to remove the four lines:
-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0
if you wanted the parent tabLayout to be formLayout-ed to the window edges you would need to create a brand new formLayout above the tabLayout and add these deleted lines at the end, but it’s probably not necessary as the tabLayout should automatically fill the window in the absence of any higher layout directives.
Also, if you are going to make your windows NON-sizeable (-s 0), make sure you specify an initial window size!! your code creates a window nearly 2000 pixels wide on my setup!
:nathaN
hi nathan,
it worked thnx for the help. i get what you explained to me. stupid i didnt find that my self
… ( but that s what you get when you try to learn from other scripts … you also copy the wrong things
)
and the stuff with the 2000 pixels could be right… since i use a full HD screen and i want the window to be at the max of my screen. ( like full screen )
So i gues thats why its also that big when you open it?
but still thnx allot … now i finaly can fill in the second tab.
I’m not sure how many folks or studios have made the jump to Maya 2011, but one of the things that frustrated me going into 2011 was making UI’s with QT. I’d never used it before and while setting it up was simple enough, none of the accessible interface items was listed in the Maya Help. So I threw together a quick tutorial on how Maya interfaces with QT’s .ui file and how the Mel commands can be accessed through it. It’s not exhaustive by any means, but I figured it may help someone else out who’s trying to start as I was.
If there are errors on anything, please let me know. I tested it thoroughly, but when you’re in the groove you miss stuff. Hope it helps someone.
Hi i was about to make a new thread then i saw this about UI so I figured the answer to my question might be interesting in this post. I made a short script to create some rotations to simulate some wind in tree leaves,
proc applyExpressionToSelection(){
string $sel[] = `ls -sl`;
for($object in $sel){
expression -s ("float $timeStamp = sin (time * .8) * 1.5; " +
$object + ".rotateZ = $timeStamp") -o $object -ae 1 -uc all;
}
}
applyExpressionToSelection();
[i]that worked nicely then i realised to be able to make this a little more random it would be nice to change the values time is multiplied by, also this being directed at ppl who never use mel, i made a little UI, (my first attempt at scripting one but then things got a little too complicated); After a lot of trial and error I found a very similar script to what i'm trying to do at the bottom of : [http://forums.cgsociety.org/archive/index.php/t-153797.html](http://forums.cgsociety.org/archive/index.php/t-153797.html) and worst case I could just use that instead, but I'd like to know why my script isn't working if anyone can help me out, the problems seems to be I can't efficiently use the values from my sliders in the expression creation... but i don't understand where I got it wrong. I determined this piece of code works fine if I declare the variables with the following value : [/i]
proc applyExpressionToSelection(){
float $speed_factor = 2;
float $rotation_float = 2;
string $sel[] = `ls -sl`;
for($object in $sel){
expression -s ($object + ".rotateZ = sin (time *" + $speed_factor + ")*" + $rotation_float + ";") -o $object -ae 1 -uc all;
}
};
[i]However that means I'm stuck with value 2 and 2, so here is the whole code with the UI if anyone knows what I didn't do right, I'd be grateful for the help.[/i] [i]All I get is // Error: but I don't know from what ...
[/i]
//expression creation rotateZ with sin(time) and some multipliers
global proc applyExpressionWind()
{
float $speed_factor;
float $rotation_float;
$speed_factor = `floatSliderGrp -q -v speedFactor` ;
$rotation_float = `floatSliderGrp -q -v rotationFloat` ;
string $sel[] = `ls -sl`;
for($obj in $sel){
expression -s ($obj + ".rz = sin(time *" + $speed_factor + ")*" + $rotation_float + ";") -o $obj -ae 1 -uc all;
}
};
//UI
global proc windTree_UI()
{
if (`window -exists treeWindow`)
deleteUI treeWindow;
$all_selected_objects =`ls -selection`;
window -widthHeight 300 200 -resizeToFitChildren 1 -title "Wind in trees" treewindow;
columnLayout -adjustableColumn true;
$obj_name_text =
`textField
-editable 0
-width 400
-text $all_selected_objects `;
separator -height 20 -width 120;
text -label "Choose two time multipliers, try keep the values between 0.5 and 5.0";
$speedFactor =
`floatSliderGrp
-minValue -5
-maxValue 5
-fieldMinValue -5
-fieldMaxValue 5
-field 1
-label "Speed"
`;
$rotationFloat =
`floatSliderGrp
-value 1.0
-minValue 1.0
-fieldMinValue 1.0
-field 1
-label "Rotation"
`;
separator -height 20 -width 120;
$execution_button=
`button
-label "Execute!"
-command " applyExpressionWind();"`;
$button_close=
`button -label "Close" -command "deleteUI treewindow"`; showWindow;
};
[i]Edit : I figured out what was wrong after modifying many things, and considering the amount of time spent on this I’ll post the answer here for anyone who has the same problem
the section with the sliders is now written as :
[/i]floatSliderGrp
-minValue -5
-maxValue 5
-fieldMinValue -5
-fieldMaxValue 5
-field 1
-label “Speed”
speedFactor;
floatSliderGrp
-value 1.0
-minValue 1.0
-fieldMinValue 1.0
-field 1
-label "Rotation"
rotationFloat;
The rest of the code is the same.
I’m sorry if this has been asked already, but I haven’t found any real solution to this.
In Maya version 2009 and older, is there a good way of automatically setting the window height based on the content of the gui? I use collapsaeble frameLayouts, so I want the window to shrink when they are collapsed. Also a check of this kind would be useful for overriding windowPrefs.mel
In 2011 this is not a problem as it adjusts window height automatically. But there’s another problem and that is that I get different heights from the frameLayouts in 2009 and 2011, so I can’t use that to add and subtract from the window height. Unless I have some kind of version checker, but I don’t know how to do that. Don’t want to split it into two scripts either, but I might have to?
I am afraid there is no easz solution to this, you can use the “about” command to check the maya version.
Not sure about the former of your issues, but a version checker is fairly easy.
if (getApplicationVersionAsFloat() <= 2009){
print "Do stuff for 2009 versions and lower";
}else{
print "Do stuff for anything over 2009";
}
Here’s an example for equal to a version (5) between two versions or a range and greater than:
string $version = `about -v`;
string $versionBuffer[];
tokenize $version "." $versionBuffer;
$version = $versionBuffer[0] + "." + $versionBuffer[1];
float $versionFloat;
if ($versionFloat == 5.0)
$doThis = 6;
else if ($versionFloat >= 7.0 && $versionFloat <= 2010.0)
$doThis = 5;
else if ($versionFloat >= 2011)
$doThis = 3;
return $operationType;
[b][size=2]
[/b][/size]
Thanks! I decided the easiest way to do this was to just set window size to changeable when in 2009 or bellow. Too much work trying to calculate what the correct window size should be.
I have a more specific UI question if you don’t mind. My script has an interface like this:
global proc Demo(){
if(`window -exists DemoUI`){
deleteUI DemoUI;
}
window -s 1 -title ("Demo") DemoUI;
frameLayout -label "Super Frame" MainFrameLayout;
columnLayout MainColumn;
//Frame 1
frameLayout -label "Layout 1" -collapsable 1 layoutUVM;
columnLayout ;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "One" -width 108 UpButton;
button -label "Two" -width 108 DownButton;
setParent ..;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "Three" -width 108 LeftButton;
button -label "Four" -width 108 RightButton;
setParent ..;
setParent ..;
setParent ..;
//Frame 2
frameLayout -label "layout 2" -collapsable 1;
columnLayout ;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "One" -width 108 UpButton;
button -label "Two" -width 108 DownButton;
setParent ..;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "Three" -width 108 LeftButton;
button -label "Four" -width 108 RightButton;
setParent ..;
setParent ..;
setParent ..;
//Frame 3
frameLayout -label "layout 3" -collapsable 1;
columnLayout ;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "One" -width 108 UpButton;
button -label "Two" -width 108 DownButton;
setParent ..;
rowLayout -cw2 108 108 -numberOfColumns 2;
button -label "Three" -width 108 LeftButton;
button -label "Four" -width 108 RightButton;
setParent ..;
setParent ..;
setParent ..;
showWindow DemoUI;
}
Demo();
What I can’t figure out is how to vertically split the window into two rows, so i have all of these rowLayouts and buttons on the left side, and other things such as an attached panel to the right. Like the hyperShade is split with a list of shaders on the left and then the workspace to the right.
I got it working now, but only in m2011. In 2009 the same script complains about my first framelayout having too many children… :-\
I have been trying to create a python maya UI with a file browse directory button… is there a preferred command to do this?
perhaps textFieldButtonGrp()?
or attrNavigationControlGrp()?
or something else?