View Full Version : How to stop a script?


sepehr
08 August 2008, 09:37 PM
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

brentelliott
08 August 2008, 11:25 PM
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.

Buexe
08 August 2008, 11:36 PM
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.

NaughtyNathan
08 August 2008, 09:25 AM
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!! :D )

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

:nathaN

sepehr
08 August 2008, 12:41 AM
Thank you so much!

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

Cheers!
Sepehr

CGTalk Moderation
08 August 2008, 12:41 AM
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.


1