class StationTypology: def __init__(self, areaName, bufferDistance): self.areaName = areaName self.bufferDistance = bufferDistance def BusinessDensity(self): try: # Make a temporary table in memory based on query of feature class query = ("""\"AreaName\" = '""" + self.areaName + """' AND \"BufferDistance\" = """ + str(self.bufferDistance) + """ AND \"UseType\" = 'Business'""") arcpy.MakeTableView_management("LANDUSE", "business", query) # Calculate the sum of floor space, from above table arcpy.Statistics_analysis("business", "in_memory\\businessStatistics", [["FloorArea", "SUM"]]) # Use SearchCursor to access table records and store rows in a variable rows = arcpy.SearchCursor("in_memory\\businessStatistics", "", "", "SUM_FloorArea", "") # Table has one row; access with iteration, grab value of SUM_FloorArea for row in rows: businessDensity = row.SUM_FloorArea del rows # Housekeeping arcpy.Delete_management("business") # Housekeeping arcpy.Delete_management("in_memory\\businessStatistics") # Housekeeping return businessDensity except: try: del rows # Housekeeping arcpy.Delete_management("business") # Housekeeping arcpy.Delete_management("in_memory\\businessStatistics") # Housekeeping except: pass
Solved! Go to Solution.
Set arcpy.env.addOutputsToMap to False at the beginning, then back to True when you're done.
add_to_map = arcpy.env.addOutputsToMap arcpy.env.addOutputsToMap = False ... Your code ... arcpy.env.addOutputsToMap = add_to_map
This seems to be broken. Setting to false does not stop the output being added to the map.