I've got a short Maya script that just rotates the camera continuously in a circle. Problem is, when I try to run the script, once it's running I can't close the application until I kill the script. I'm using cmds.refresh() but that only refreshes the UI and still delays other operations (like closing the program). I understand I can just kill the script by hand but I would like to be able to do it programmatically through callbacks or some other such thing.
Here's what my code looks like right now:
import sys
import time
import maya.cmds as cmds
import maya.api.OpenMayaUI as omui
view = omui.M3dView.active3dView()
currentCamera = view.getCamera()
while(True):
cmds.orbit(currentCamera, ha = 1)
view.setCamera(currentCamera)
cmds.refresh()
time.sleep(.01)
Basically is there something I can put in the while() instead of "True" that will kill the script automatically when you go to close the program? Or something I could be doing differently altogether?