I have made an ArcMap add-in which has the condition that only one feature can by selected a computed. If there are more features selected or no feature in the selection, a message will pop up that the script should be terminated. I am using the sys
module and sys.exit(0)
in the condition, but this command terminates ArcMap.
Is there something else that terminates only the running Python script, but not ArcMap entirely?
EDIT: I'm using ArcMap 10.4.
-
Please read what you have written in your mind.nickves– nickves2017年07月31日 08:21:52 +00:00Commented Jul 31, 2017 at 8:21
-
I just tried this in 10.4.1 and it didn't shut down my arcmap....NULL.Dude– NULL.Dude2017年07月31日 15:32:36 +00:00Commented Jul 31, 2017 at 15:32
-
in 10.2 it does - tested todaynickves– nickves2017年07月31日 18:11:06 +00:00Commented Jul 31, 2017 at 18:11
2 Answers 2
That's cool, I didn't know you could shutdown Arc by calling sys.exit()
.
The in-program python interpreter shuts down with the exit call and since the ArcGIS is depended on it the action shut downs the whole system? Makes sense in this context.
For what you asking, you could wrap your logic in a function and return None
at the end of it.
Wrap your code in a function and use return
whenever you wish to terminate the script.
def RunScript ():
#code
#code code
#code
#if selection
if sel:
return
#continue code
RunScript ()