Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Mel Script Not Working on MAYA 2018

ebarrettK5ZLP
Explorer
Explorer

Mel Script Not Working on MAYA 2018

ebarrettK5ZLP
Explorer
Explorer

Hey,

 

How is it going, I have this Mel script but for some reason it works on Maya 2022 but it has errors on Maya 2018. Would any one be able to point out why it my not be working. Thank you

 

//Returns TimeWarp State as Enabled/Disabled
global proc string checkTimeWarpState ()
{

global int $timeWarpState;
string $state;

$timeWarpState = `getAttr time1.enableTimewarp`;

if ($timeWarpState == 0)
{
$state = "Disabled";
//print("checkTimeWarpState: " + $state + "\n");
}
else if ($timeWarpState == 1)
{
$state = "Enabled";
//print("State: " + $state + "\n");
}
return $state;

} // TimeWarp State return end

global proc Enable_TimeWarp_HUD ()
{

global int $timeWarpState;

//Enable timeWarp
EnableTimeWarp;

//set TimeWarp State to var to read later
$timeWarpState = `getAttr time1.enableTimewarp`;
print("timeWarpState: " + $timeWarpState + "\n");

print("checkTimeWarpState: " + checkTimeWarpState() + "\n");

if ($timeWarpState == 1){

//Turn on heads headsUpDisplay
headsUpDisplay -section 3
-block 0
-blockSize "large"
-label "TimeWarp :"
-labelFontSize "large"
-command "checkTimeWarpState()"
-event "SelectionChanged"
-nodeChanges "attributeChange"
HUDTimeWarpEnabled;

}else if ($timeWarpState == 0){

//setTimeWarp();
headsUpDisplay -rem HUDTimeWarpEnabled;

}//check enabled/disabled end
}//EnableHUD end

0 Likes
Reply
201 Views
2 Replies
Replies (2)

Kahylan
Advisor
Advisor

Hi!

 

The problem comes from the fact that the toggle Command "EnableTimeWarp" that automatically switches timewarp state didn't exist yet in Maya 2018. If you use an if/else setAttr Toggle to do the same it should work:

//Returns TimeWarp State as Enabled/Disabled
global proc string checkTimeWarpState ()
{

global int $timeWarpState;
string $state;

$timeWarpState = `getAttr time1.enableTimewarp`;

if ($timeWarpState == 0)
{
$state = "Disabled";
//print("checkTimeWarpState: " + $state + "\n");
}
else if ($timeWarpState == 1)
{
$state = "Enabled";
//print("State: " + $state + "\n");
}
return $state;

} // TimeWarp State return end

global proc Enable_TimeWarp_HUD ()
{

global int $timeWarpState;

//Enable timeWarp
$timeWarpState = `getAttr time1.enableTimewarp`;

if ($timeWarpState == 1){
    setAttr "time1.enableTimewarp" 0;
}
else {
    setAttr "time1.enableTimewarp" 1;
}

//set TimeWarp State to var to read later
print("timeWarpState: " + $timeWarpState + "\n");

print("checkTimeWarpState: " + checkTimeWarpState() + "\n");

if ($timeWarpState == 1){

//Turn on heads headsUpDisplay
headsUpDisplay -section 3
-block 0
-blockSize "large"
-label "TimeWarp :"
-labelFontSize "large"
-command "checkTimeWarpState()"
-event "SelectionChanged"
-nodeChanges "attributeChange"
HUDTimeWarpEnabled;

}else if ($timeWarpState == 0){

//setTimeWarp();
headsUpDisplay -rem HUDTimeWarpEnabled;

}//check enabled/disabled end
}//EnableHUD end

Enable_TimeWarp_HUD ();

 

I hope this helps!

0 Likes

ebarrettK5ZLP
Explorer
Explorer

Thank you so much @Kahylan , That worked perfectly

0 Likes