I am trying to convert a Python script I've made into a tool to make it easier for people not familiar with Python to use.
The job of the script is to take a template mxd with the background layers and layout view already made and upload a CSV to it and run a series of analysis and export a map.
I was wondering if it was possible to create a tool that could work inside of a closed mxd, or if that could only be done through Python.
Python script code snippet:
mxd = arcpy.mapping.MapDocument(r'Template mxd') df = arcpy.mapping.ListDataFrames(mxd) # adds all background layers addLayer = arcpy.mapping.Layer(r"background layer 1") arcpy.mapping.AddLayer(df, addLayer,"BOTTOM") addLayer = arcpy.mapping.Layer(r"background layer 2") arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") ... more layers added ... # Change coordinate system prjPath = "c:\program files (x86)\arcgis\desktop10.2\Coordinate Systems\Projected Coordinate Systems\Continental\North America\Canada Lambert Conformal Conic.prj" spatial_ref = arcpy.SpatialReference(prjPath) df.spatialReference = spatial_ref #upload excel file and display x/y coordinates arcpy.env.workspace = r"Template mxd" arcpy.TableToTable_conversion(outLayer, table2table, "temp") x_coords = "Longitude" y_coords = "Latitude" out_Layer = "outLayer" prjPath2 = "c:\program files (x86)\arcgis\desktop10.2\Coordinate Systems\Geographic Coordinate Systems\North America\NAD 1983.prj" arcpy.MakeXYEventLayer_management (in_Table, x_coords, y_coords, out_Layer, prjPath2) arcpy.SaveToLayerFile_management(out_Layer, saved_Layer) addLayer = arcpy.mapping.Layer(saved_Layer) arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
This isn't the full code but it's just a sample and hopefully it shows what I mean when I say a closed (not currently open) mxd.