2

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.

Result window showing place where script run would be

  • 1
    Looks 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 Jul 31 '15 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 result – KHibma Jul 31 '15 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 Jul 31 '15 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 Jul 31 '15 at 21:43
  • this is a sub case of gis.stackexchange.com/questions/138789/… – matt wilkie Sep 10 '15 at 17:58
0

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.