How to stop a script?


#1

Hello!

There are times that my scripts get into infinite loop and I don’t know any way to stop them but to force Maya to close. Is there any other way?

Thanks,
Sepehr


#2

Nope, you’ve gotta just kill the process.

One tip while you’re testing loops that have the potential to go infinite on you, is to put a catch in there that it’s only allowed to run, say 100,000 times before breaking the loop. That way you can test some crazy while loops without having to restart Maya when you forget to increment a counter.


#3

For stuff like “while” loops I do stuff similar to what brentelliott already mentioned. Additionally the progressWindow command allows you to stop a loop/script by checking if the “esc” key has been pressed. Sometimes this is also helpful.


#4

This is what I do:

put a line inside the loop like:

if (filetest -f c:\breakloop.txt) break; // or use “error” instead of “break”

then… if your program gets into a loop you want to break out of just create a file called “breakloop.txt” on the root of your C: drive. (don’t forget to delete this file before you run your script again!! :smiley: )

(and believe it or not this doesn’t significantly alter the execution speed by any noticable amount!)

:nathaN


#5

Thank you so much!

Your answers helped me a lot.
I had no idea about these so many different methods!

Cheers!
Sepehr


#6

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.