Help! I am trying display the output of my script on an mxd once it is created. To do this, i created a function at the end of my class that handles all mapping. I have tested the code up until the mapping function and it works great. But when i try to run the script with the mapping function, the output file is empty and so is the layer file i created with it. Does anything stand out that might edit/save over my output file?
def MapOutput(self): '''This function Creates a map document, adds the output data, and exports a thumbnail of the data.''' # Create map document features. mxd = arcpy.mapping.MapDocument(self.MapDocument) dfs = arcpy.mapping.ListDataFrames(mxd) df = dfs[0] # Create a layer file from input data and symbolize it. arcpy.MakeFeatureLayer_management(self.dBaseComparison(), 'Layer') arcpy.ApplySymbologyFromLayer_management('Layer', self.OutSymb) # Add symbolized layer to map document. addLayer = arcpy.mapping.Layer('Layer') arcpy.mapping.AddLayer(df, addLayer) # Create a copy of the map document and save it. copyName = self.MapDocument[:-4] + "_Output.mxd" mxd.saveACopy(copyName) del mxd # Export a PNG image of the map document. mxd = arcpy.mapping.MapDocument(copyName) arcpy.mapping.ExportToPNG(mxd, copyName[:-4] + "_Map.png") del mxd
أكثر...
def MapOutput(self): '''This function Creates a map document, adds the output data, and exports a thumbnail of the data.''' # Create map document features. mxd = arcpy.mapping.MapDocument(self.MapDocument) dfs = arcpy.mapping.ListDataFrames(mxd) df = dfs[0] # Create a layer file from input data and symbolize it. arcpy.MakeFeatureLayer_management(self.dBaseComparison(), 'Layer') arcpy.ApplySymbologyFromLayer_management('Layer', self.OutSymb) # Add symbolized layer to map document. addLayer = arcpy.mapping.Layer('Layer') arcpy.mapping.AddLayer(df, addLayer) # Create a copy of the map document and save it. copyName = self.MapDocument[:-4] + "_Output.mxd" mxd.saveACopy(copyName) del mxd # Export a PNG image of the map document. mxd = arcpy.mapping.MapDocument(copyName) arcpy.mapping.ExportToPNG(mxd, copyName[:-4] + "_Map.png") del mxd
أكثر...