|
Hello Everyone,
First, I just want to say that I have around 5 days of MEL experience at this point, so I am an extreme novice and most likely will not understand some of the answers I will receive. So please forgive my naivety on the subject. But with that being said, I have learned quite a bit thus far.
I am trying to create a window with two buttons. One button to read “Get TransX”. The second button to read “Set TransX”. With the “Get TransX” button, I want to get the translateX value from a currently selected object. With the second “Set TransX” button, I want to be able to assign that same translateX value (the value returned from the the first button) to a second/newly selected object. Hope that makes since. I have only attempted to deal with the first button at this point...with failure I might add.
Here is my code thus far:
/////////////////////////////////////////////////////////////////////////////
//delete UI if it exists already
if (`window -exists modelHelper` == 1)
{
deleteUI modelHelper;
}
//Declare Variables Needed
string $SelObj01[] =`ls-sl`;
float $FirstSelObjTranX;
//Back UP float $FirstSelObjTranX = `getAttr $selObj.translateX`;
//Create the UI
window
-title “Model Helper”
-widthHeight 325 600
-sizeable 0
-backgroundColor .8 .9 1
modelHelper;
rowColumnLayout -numberOfColumns 2
-columnWidth 1 150
-columnWidth 2 150
-columnSpacing 1 8;
text -label “Translates” -align “left” -font “boldLabelFont”;
text -label “ “ -align “right” -font “boldLabelFont”;
button -label “Get Trans X” -command “getTransXproc” getTransX;
button -label “Set Trans X” -command setTransX;
showWindow;
proc getTransXproc()
{
string $SelObj01[] =`ls-sl`;
float $FirstSelObjTranX = `getAttr $SelObj01.translateX`;
}
////////////////////////////////////////////////////////////////////////////
The problem I have is that my procedure will run/update the translate X value on my current selected object if I execute it line by line by highlighting and hitting my enter key on the num key pad. But if I click on the first “Get TransX” button in the UI, which is suppose to execute the proc by a -command flag, it does not update the translateX value at all. Again, hope that makes sense.
Can any kind MEL souls explain to me my errors in the coding?
Thanks! :)
Dave
|