Hi,
Here is my issue, I want to create a tool to change a string Value:
Theoric Example: Variable called "Name One"
Click on the tool to update Variable in "Name Two"
MEL Script:
string $Target = "NAME_ONE";
string $window = `window -title "Long Name"
-iconName "Short Name"
-widthHeight 200 55`;
columnLayout -adjustableColumn true;
button -label "Change Name" -command "NewName($Target)";
button -label "Close" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
proc NewName(string $Target){
$Target = "NAME_TWO";
print $Target;
}
print $Target;
During the procedure, it seems to work, nut as soon as I print $Target again, it remains, "Object_One"
Anyone would know a trick?
Solved! Go to Solution.
Solved by t.pansiot. Go to Solution.
Hi!
Try something like this:
global proc string NewName(string $name){
$name = "NAME_TWO";
return $name;
}
NewName("whatever");
print `NewName("whatever")`;
print (NewName("whatever"));
Here is the solutions: string should be "global string" and it should be called inside the proc like this:
global string $Target = "NAME_ONE";
string $window = `window -title "Long Name"
-iconName "Short Name"
-widthHeight 200 55`;
columnLayout -adjustableColumn true;
button -label "Change Name" -command "NewName()";
button -label "Close" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
global proc NewName(){
global string $Target ;
$Target = "NAME_TWO";
print $Target;
}
print $Target;
Hi!
Yes I tested this too and it did not work, but I guess this was, because I had already declared the variable based on your example code and would have needed to close and reopen Maya.
Can't find what you're looking for? Ask the community or share your knowledge.