What do I need to do in order to get a custom arcpy script to save an execution run into the Results window, and/or just straight to an .rlt
file directly?
The script is run from the command line and isn't in a toolbox.
Motivation: I use results as documentation, to see what has been done in a particular project, and to recreate particular steps dynamically at will, confident that I will get the same outcome. Significant steps are saved as .rlt for future reference and re-use in other projects. I want to capture my non-toolbox scripts as well as model scripts in this manner as well as stock tools.
-
1Looks like ArcPy gp tools return a result object you can save using the saveToFile method. resources.arcgis.com/en/help/main/10.2/index.html#//…Eok– Eok2015年07月31日 18:46:22 +00:00Commented Jul 31, 2015 at 18:46
-
@EokN. answer is correct to save a result to a file. But the only way to get a result is to have it run as a tool. You wont/cant see a py script execution in the results window. You could wrap your script as a script tool and execute it from inside ArcGIS. That would give you a resultKHibma– KHibma2015年07月31日 19:04:42 +00:00Commented Jul 31, 2015 at 19:04
-
@EokN. True, although that would have to be done for each GP tool that is called within the script, creating separate files for each. Back to the question: Is there a reason you don't want to build your scripts into toolboxes? You wouldn't necessarily have to change the script, in fact you could write a generic toolbox to run a script with given parameters....that would 'document' that you ran it, etc.Evil Genius– Evil Genius2015年07月31日 19:04:49 +00:00Commented Jul 31, 2015 at 19:04
-
@EvilGenius adding a script to a toolbox tedious, so I tend to avoid it unless it's something that warrants the extra work. Consequently only about a 3rd of the scripts I use end up being recorded. :-/ The idea of a generic "run this" tool is interesting. I might explore that.matt wilkie– matt wilkie2015年07月31日 21:43:32 +00:00Commented Jul 31, 2015 at 21:43
-
this is a sub case of gis.stackexchange.com/questions/138789/…matt wilkie– matt wilkie2015年09月10日 17:58:49 +00:00Commented Sep 10, 2015 at 17:58
1 Answer 1
As commented by @KHibma:
the only way to get a result is to have it run as a tool. You wont/cant see a py script execution in the results window. You could wrap your script as a script tool and execute it from inside ArcGIS. That would give you a result