-
-
Save FurnasAZ/efdcdf9eb9505919d250ae33522afa40 to your computer and use it in GitHub Desktop.
Revisions
-
TheBryanMac created this gist
Oct 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #Name: ArcMap Layers to LYR Files with Python #Author: Bryan McIntosh #Description: Iterate through an ArcMap MXD, and export all layers to LYR files. import arcpy, os #Set the working directory to where the Python file is stored cwd = os.getcwd() #Set the location of the MXD file mxdPath = os.path.join(cwd,"MyMap.mxd") #Set the location to store LYR files layersOutPath = os.path.join(cwd,"export") #Get the MXD and layers mxd = arcpy.mapping.MapDocument(mxdPath) layers = arcpy.mapping.ListLayers(mxd) for layer in layers: if str(layer.name) == str(layer.longName): tempOutName = str(layer.name).replace("/","-") tempOutName = str(tempOutName).replace(":","-") fn = os.path.join(layersOutPath, str(tempOutName) + ".lyr") layer.saveACopy(fn) print "LYR Extraction Complete"