Forum: Poser Python Scripting


Subject: Is there a universal "stop this script here" command?

HartyBart opened this issue on Jul 19, 2020 ยท 6 posts


adp001 posted Mon, 20 July 2020 at 2:54 AM

There is a Python function to abort a script: sys.exit()

But in Poser-Python this stops not only the script. It stops Poser :)

Nonetheless, there is a another, "pythonic" way to interrupt a running script (even if it's nicer done with program logic).

class StopScript(Exception):
    pass


def abc(parm):
    if parm > 10:
        raise StopScript()
    else:
        print parm

try:
    abc(20)
except StopScript:
    print "Script aborted"