[Maya MEL] Queried command not working (but no error/warning errors either)

Hi,

I have this simple tool that shifts all keyframes. When I run in the script editor, it does not produce error or warning line but the button does not work either.

The remBet() and the addBet() works manually. So I guess the offending procedure is

button -l “-” -w 45 -c (“remBet(” + $customFrames + “)”);
button -l “+” -w 45 -c (“addBet(” + $customFrames + “)”);

The problem is when I use a print command to troubleshoot, all seems good. But again, it does not do anything.

Is there a way around this? Thank you for looking at the problem.

if (`window -exists btRU`){
    deleteUI -window btRU;
}

window -title "And/Remove Inbetween" 
       -wh 300 100
       -rtf false
       btRU;

columnLayout -adj 1 mainC;


rowColumnLayout -nc 4
                rc3;
                
text -l "Custom Frames " -al "right";
intField -v 0 -w 100 -min 0 cFrames;
$customFrames = `intField -q -v cFrames`;
button -l "-" -w 45 -c ("remBet(" + $customFrames + ")");
button -l "+" -w 45 -c ("addBet(" + $customFrames + ")");
    
 
setParent mainC;

showWindow;

//int $addNumber;

global proc addBet (int $addNumber) {
    for ($i = 0; $i < $addNumber; ++$i) {
        timeSliderEditKeys addInbetween;
    }
}

//int $remNumber;

global proc remBet (int $remNumber) {
    for ($i = 0; $i < $remNumber; ++$i) {
        timeSliderEditKeys removeInbetween;
    }
}

$customFrames Is set to 0 all the time. I changed the code a bit to move the query of cFrames into the procedures.

if (`window -exists btRU`){
    deleteUI -window btRU;
}

window -title "And/Remove Inbetween" 
       -wh 300 100
       -rtf false
       btRU;

columnLayout -adj 1 mainC;


rowColumnLayout -nc 4
                rc3;
                
text -l "Custom Frames " -al "right";
intField -v 0 -w 100 -min 0 cFrames;

// This only gets set once to 0 it being the initial value of cFrames
// $customFrames = `intField -q -v cFrames`;

button -l "-" -w 45 -c ("remBet()");
button -l "+" -w 45 -c ("addBet()");

setParent mainC;
showWindow;

proc addBet () {
    int $addNumber = `intField -q -v cFrames`;
    for ($i = 0; $i < $addNumber; ++$i) {
        timeSliderEditKeys addInbetween;
    }
}

proc remBet () {
    int $remNumber = `intField -q -v cFrames`;
    for ($i = 0; $i < $remNumber; ++$i) {
        timeSliderEditKeys removeInbetween;
    }
}

Hope this helps.

1 Like

Works as expected mate. Thank you!