I have ArcMap 10.1 SP1 (Build 3143) for Desktop. I'm trying to execute the following simple code.import arcpy
class Toolbox(object):
def __init__(self):
self.label = 'Tools'
self.alias = 'Tools'
self.tools = [Tool]
class Tool(object):
def __init__(self):
self.label = 'Get it to work'
self.canRunInBackground = False
def getParameterInfo(self):
parameters = []
return parameters
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd)[0]
layer = arcpy.mapping.Layer(r'O:\shp\mn.lyr')
arcpy.mapping.AddLayer(df, layer)
return
It does not raise any exceptions and the layers are added to the dataframe but they disappear as soon as they're added. I'm trying to automate map production and I need to add these layers.