Tuesday, December 18, 2012

Using env.addOutputsToMap

The environmental variable addOutputsToMap prevents geoprocessing task results from being displayed in the TOC.  This environmental property by default is set to true, so every tool's result will display in the table of contents in ArcMap.

When developing python add-ins, you should utilize this tool to prevent sub-processes results from being added to the map.  A good example of this, is if your python add-in creates a table if it doesn't exist for logging purposes.  Your end user does not want to see this table, or know it exists, but if addOutputsToMap is set to true, the value will display in the table of contents.  Changing it to false would prevent the data from showing.

Example:
from arcpy import env
env.addOutputsToMap = false
#... perform GP task...
env.addOutputsToMap = true

Enjoy