1

I have a python script where I write result into a text file and I don't want to add the text file in my map document. But it is added automatically.

I tried with this line:

arcpy.env.addOutputsToMap = False

but it doesn't work.

import arcpy
arcpy.env.addOutputsToMap = False

txt_file = arcpy.GetParameterAsText(0)
fichier = open(txt_file, "w")
fichier.write("test")
fichier.close()

Are there any way to not add the text file automatically?

3

I copied your script exactly as it is and exposed a single parameter as shown below:

Script Properties

When I run this and choose my aaa.txt file it runs, adds "test" and completes. It does not add it to the map document. Are you setting the parameter as shown above?

  • I put "output" in the direction property. – CptGasse Aug 24 '16 at 15:46
  • 2
    It does not need to be output as you are not feeding your text file out of your script as an output could potentially feed into another tool if for example you had placed this in a model. As it stands this script tool creates no output it simply executes. – Hornbydd Aug 24 '16 at 15:50
  • Are you running this in the ArcGIS Python window? If so, maybe the Geoprocessing option to add results to the display is over-ridding arcpy.env. – GBG Aug 24 '16 at 22:44

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.