AnsweredAssumed Answered

Making layers persist in TOC after python toolbox execution completes

Question asked by sjbosher on Nov 14, 2014
Latest reply on Nov 14, 2014 by sjbosher

Hi,

I am on ArcGIS 10.1 SP1 (Build 3143)

I have a python toolbox that is producing a number of shapefile outputs that I would like to add to the ArcGIS TOC.

 

Problem I am having is that whilst the layers add to the TOC while the tool is running when it completes the layers are deleted, and I can't seem to find a way to avoid this.

 

Anybody have any ideas? My code (pretty standard) is below:

 

mxd = arcpy.mapping.MapDocument("CURRENT")

df  = arcpy.mapping.ListDataFrames(mxd."*")[0

addLayer = arcpy.mapping.Layer(outputFeatureclass)

arcpy.mapping.AddLayer(df, addLayer,"BOTTOM"

arcpy.RefreshTOC()

arcpy.RefreshActiveView()

 

Thanks for any help!

 

Steve

Outcomes