Exit in Spaceclaim Script

Erik Kostson
Erik Kostson Member, Employee Posts: 87
First Answer Name Dropper First Anniversary Ansys Employee
edited February 9 in General Language Questions

Trying to exit from a spaceclaim script using sys.exit(), but that does not work (say sample code below gives an error on last line). Does anyone know why and how one can exit a code in spaceclaim.

# Python Script, API Version = V232
import sys
for i in range(10):
    print(i)
    if i == 5:
        print('hi')
        sys.exit()

Comments

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 239
    First Anniversary First Comment 5 Likes Ansys Employee

    Do you mean stop the code processing or close the SC application?

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 87
    First Answer Name Dropper First Anniversary Ansys Employee
    edited February 9

    Hi

    So stopping and exiting the python script as described by the sys.exit() definition below - which does not work in SC scripting as mentioned. So we want to stop and exit the SC script, but ofcourse if you try my example in SC script that does not really work.

    'Python's exit function, sys. exit() , is a built-in method used to terminate a Python script. It raises the SystemExit exception which, if not caught, causes the Python interpreter to quit. It's commonly used to manage the termination of Python programs'