Simple MEL Help almost done.
Dashboard_avatar
Michael Park
Jun 14, 2015
Quote Reply Post id: 315335 Report Item
Currently trying to create a UI where after I selected a control on a rig in the text field I can name it whatever I want then click create to create a button for it. Doing this because having quick selection sets are very annoying sometimes with short names to represent certain controls. So MY PROBLEM is I can create ONE button so far, but when I click another control and try to name it and create another button it won't do anything... Please help and go easy on this noob... here is my code thank you.
global proc setCreateTool()
{
// Test if a window "setCreateTool" exists.
if (`window -exists setCreateTool` ==1)
// Delete if it exists.
deleteUI setCreateTool;
// Define the selection.
string $sSelection[]= `ls -sl`;
// If nothing is selected have an error...
if (size($sSelection) == 0) error "No objects selected to create set";
// So now if a window does not currently exist create one.
if (`window -exists setCreateTool` != 1)
{
window -title "Set Creation Tool"
setCreateTool; columnLayout -w 200 -h 50;
// Make a text field area for typing in control names.
textField -w 200 textFieldData;
// Make a create botton.
button -label Create -width 50 -command. "createSetFunction()";
showWindow setCreateTool;
}
}
global proc createSetFunction()
{
// GIVE A VALUE TO THE TEXT FIELD BY QUERYING!
string $tData = `textField -query -text textFieldData`;
// print $tData;
// Define the selection
string $sSelection[]= `ls -sl`;
// Use a for statement to create a loop so you can create the sets multiple times.
// Use the array that was defined for selection and variable for querying the text field.
for ($i = 0; $i < (size($sSelection)); $i = $i + 1)
{
button -label $tData -command ("select " + $sSelection[$i]);
}
}
setCreateTool;