Save all layers in map to layer files

    Table of contents
    You are currently comparing two old versions - only when you are comparing against the latest version can you revert. Return to version archive.

    Combined revision comparison

    Comparing version 14:01, 4 Oct 2011 by matt with version 14:02, 4 Oct 2011 by matt.

    Version from 14:01, 4 Oct 2011

    This revision modified by matt (Ban)

    I'm in the final stretches of building Yukon Canvec and found myself in need of repeatedly saving multiple layers to disk. I got tired of click, click, click and decided to learn a bit more about using arcpy interactively. The result is a short immediate mode python snippet:

    import arcpy
    arcpy.env.workspace = r'r:\Layers'
    layers = ['Index','Toponomy','Places of Interest','Transportation','Energy','Industrial and Commercial','Buildings and Structures','Hydrography','Water Saturated Soils','Relief and Landforms','Vegetation']
    for lyr in layers:
        arcpy.SaveToLayerFile_management(lyr, lyr + '.lyr', "RELATIVE")
    


    It's pretty slow, but not as slow as doing it all by hand! Now all that's needed is a means to make "layer =" line populated automatically from the map instead of hard coded, and then this could be attached to a button.

    Version as of 14:02, 4 Oct 2011

    This revision modified by matt (Ban)

    I'm in the final stretches of building Yukon Canvec and found myself in need of repeatedly saving multiple layers to disk. I got tired of click, click, click and decided to learn a bit more about using arcpy interactively. The result is a short immediate mode python snippet:

    import arcpy
    arcpy.env.workspace = r'r:\Layers'
    layers = ['Index','Toponomy','Places of Interest','Transportation','Energy','Industrial and Commercial','Buildings and Structures','Hydrography','Water Saturated Soils','Relief and Landforms','Vegetation']
    for lyr in layers:
        arcpy.SaveToLayerFile_management(lyr, lyr + '.lyr', "RELATIVE")
    


    It's pretty slow, but not as slow as doing it all by hand! Now all that's needed is a means to make "layer =" line populated automatically from the map instead of hard coded, and then this could be attached to a button.

        Send feedback