View Full Version : Re-evaluate Command???
Dichotomy 09-15-2003, 11:56 PM Does anyone know of a re-evaluate command?? I'm trying to put some buttons on a UI, but I want them to be able to turn off. They to are select the FK arms in an FK/IK arm setup. I want the buttons to say FK OFF when the FK is off and then Select * Joint when they are on. Right now I can only get the button to run the first time, it gives the correct answer, but then if I switch the FK on or off, the button won't change... I'm sure there is a command for this, I just can't find it.
Any help would be greatly appreciated.
Thanx
|
|
mark_wilkins
09-16-2003, 01:58 AM
You may have to delete and recreate the UI object, then refresh the window?
Not exactly sure about the exact order for doing this.
-- Mark
Dichotomy
09-16-2003, 04:27 AM
aight, I'll give that a try... Is there no command that will execute when a certain attribute is changed?? like, if *.* changes do *.
thanks again
mark_wilkins
09-16-2003, 06:06 AM
Oops, I see what you're trying to do. You're trying to change the label of the button when the checkbox is checked.
Here's one way to do it.
global proc checkboxOff() {
global string $gButtonName;
button -edit -label "checkBox is OFF" $gButtonName;
}
global proc checkboxOn() {
global string $gButtonName;
button -edit -label "checkBox is ON" $gButtonName;
}
global proc makeWindow() {
global string $gButtonName;
window;
columnLayout;
$gButtonName = `button -label "checkBox is OFF"`;
checkBox -label "Click here to affect button name" -onc "checkboxOn()" -ofc "checkboxOff()";
showWindow;
}
makeWindow;
Dichotomy
09-17-2003, 01:31 AM
excellent
that is what I am trying to do
thanks for helping a MEL-newbie out
one quick question though... if I wanted to do it based on an attribute of an object, and not a check box, would the code be similar? I guess I could just make the checkbox change the attributes of the object... right??
thanks again
mark_wilkins
09-17-2003, 03:13 AM
If you only want to depend on an attribute's value at the time the window opens, just use a getAttr to examine it. If you want to depend on an attribute's changing value while the window is open, the best way to do it is to (when the window opens) start a scriptJob that watches the attribute and updates the window when it changes. Remember to kill the scriptJob when the window closes.
-- Mark
Dichotomy
09-17-2003, 03:16 AM
that is exactly what I was looking for. I want the window to watch the attr. and then update when it changes.
Perfect!!
Thank you sooo much
Really appreciate you sharing your expertise with us
Dichotomy
09-17-2003, 03:12 PM
ok,here is a script that I worked out using both a global proc and the scriptJob... but it doesn't seem to want to work. Any ideas?
string $barth = `window -title "barthControls"`;
columnLayout;
global proc FK()
{
float $rFKcheck= `gettAttr right_wristTranslateControl.fkIkSwitch`;
if ($rFKcheck !0)
{
button -label "rFKshoulder" -command ("select FK_r_shoulderJoint");
}
else
{
button -en false -label "rFKshoulder" -command ("");
}
}
scriptJob -p $barth -ac right_wristTranslateControl.fkIkSwitch FK();
button -label "Close" -command ("deleteUI -window " + $barth);
showWindow $barth;
mark_wilkins
09-17-2003, 08:04 PM
You need to edit the button, not make new ones, in the script job. Look up the -e flag.
-- Mark
Dichotomy
09-18-2003, 03:12 AM
I checked out the -e command flag, but I can't find anything that will tell me exactly how to execute it
Here is the script that is working, minus the -e in the scriptJob that changes the button
string $barth = `window -title "barthControls" -rtf true`;
columnLayout;
float $rFKcheck = `getAttr right_wristTranslateControl.fkIkSwitch`;
if ($rFKcheck != 0)
{
button -label "rFKshoulder" -command ("select FK_r_shoulderJoint");
}
if ($rFKcheck == 0)
{
button -en false -label "rFKshoulder" -command ("");
}
global proc FK()
{
$rFKcheck= `getAttr right_wristTranslateControl.fkIkSwitch`;
if ($rFKcheck != 0)
{
***error*** button "rFKshoulder" -e -command ("select FK_r_shoulderJoint");
}
else
{
***error*** button "rFKshoulder" -e -en false -command ("");
}
}
scriptJob -p $barth -ac right_wristTranslateControl.fkIkSwitch FK;
button -label "Close" -command ("deleteUI -window " + $barth);
showWindow $barth;
I know I am using the -e wrong, but I don't know why...
mark_wilkins
09-18-2003, 03:23 AM
You shouldn't have to set the command when toggling the state. Just use
button -e -en true <name>
and
button -e -en false <name>
The name of the button goes at the end.
Also, the name is NOT the same as the label. You have to capture the name that Maya makes up for the button when you create it initially:
global string $buttonName = `button whatever`;
then use the global $buttonName (remember to declare the variable in your script job's function so it can see it) in your button -e commands.
-- Mark
Dichotomy
09-18-2003, 03:58 AM
when I try global string I get
// Error: global string $buttonName = `button rFKshoulder`;
//
// Error: Initialization of global variable "$buttonName" requires a constant value. //
mark_wilkins
09-18-2003, 04:31 AM
Sorry.
Two lines:
global string $buttonName;
$buttonName = blah blah;
-- Mark
Dichotomy
09-18-2003, 05:20 AM
aight, it's getting closer, now script is now running correctly, and the button is updating, but it is creating a new button everytime instead of editing the existing button (even though I am using the -e flag)
here's the code
string $barth = `window -title "barthControls" -rtf true`;
columnLayout;
float $rFKcheck = `getAttr right_wristTranslateControl.fkIkSwitch`;
global string $rFKbutton;
$rFKbutton = `button -label "rFKshoulder" -command ("select FK_r_shoulderJoint")`;
if ($rFKcheck != 0)
{
button -e -en true $rFKbutton;
}
if ($rFKcheck == 0)
{
button -e -en false $rFKbutton;
}
global proc FK()
{
global string $rFKbutton;
$rFKbutton = `button -label "rFKshoulder" -command ("select FK_r_shoulderJoint")`;
$rFKcheck= `getAttr right_wristTranslateControl.fkIkSwitch`;
if ($rFKcheck != 0)
{
button -e -en true $rFKbutton;
}
else
{
button -e -en false $rFKbutton;
}
}
scriptJob -p $barth -ac right_wristTranslateControl.fkIkSwitch FK;
button -label "Close" -command ("deleteUI -window " + $barth);
showWindow $barth;
I declared the global string twice, but it didn't seem to make MAYA mad,
mark_wilkins
09-18-2003, 05:24 AM
The solution is to remove one line of code. I'm leaving it up to you to figure out which one. :)
-- Mark
Dichotomy
09-20-2003, 01:17 AM
alright, I got the script to work the way I need it to.
Is there a way to make the buttons form into two columns in the UI window??
I have too many buttons and there isn't enough room on the screen, so I need to either have a scroll or (preferably) two columns, so that all of the buttons appear at one time.
Thanks
mark_wilkins
09-20-2003, 01:22 AM
formLayout is the best way to do that.
-- Mark
Dichotomy
10-08-2003, 01:07 AM
I finally got it to work just exactly the way that I wanted. I actually used the rowColumnLayout, which worked great.
Thanks for the help with this. I would have thanked you sooner but I left and got married, so I was away for a couple weeks.
oh, picking up your book later in the week... REALLY excited about it!!!
Thanks Again :beer:
zachgrachan
10-08-2003, 03:10 AM
its a great book, about halfway through it right now!
CGTalk Moderation
01-16-2006, 03:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.