• Advertisement
Sign in to follow this  

MEL SCRIPTING HELP?? How can i create a time-based loop???

This topic is 3569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello all, i have been working for weeks on how to create a loop in mel that will continuously repeat a sequence of mel scripts (that i have already written) until i escape out of the loop. basically, the mel commands that i want to loop indefinitely do things like read in an external text file (that is constantly changing) and move the camera to that possition. i have created a button for these commands, and if i continue to hit the button, then the camera will move. however, i need to automate this task with a loop and make the camera move on its own (in real time.) i don't have very much experience in looping and whenever i have tried to create a loop it either crashes the program or if i set a number of times to loop through, then it is done in a couple of seconds. so, does anyone have any ideas on how to either slow down the process for looping or how to set it to loop every second??? any help would be greatly appreciated. i am thinking about using a "for" loop, but i can't figure out how to get it to only loop every second. maybe there's a way to read the system clock and do it that way?!? please help.

Share this post


Link to post
Share on other sites
Advertisement
you can't really do this in mel. Creating the loop:

while(1)
{
// call scripts
}


will just prevent Maya ever returning to do what it needs, and your GUI will hang. Not a great idea ;)

Generally you have 2 options.

1. use an expression, and drive that by the constant "frame" or time1.outTime. This expression will then be called whenever the time changes.

2. Use a scriptJob to call some mel script on the time changed, or gl frame trigger messages.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement