Tuesday, 22 March 2016

arcgis 10.2 - arcpy.mapping.ListLayers() without calling current mxd document


How can I use the arcpy.mapping.ListLayers() function without calling the current mxd? I'm hoping to run the Python script without having an ArcMap document open.


My setsymbology code runs extremely slowly as it is now. I could do it faster manually, and my computer is definitely not the limiting factor. I'm guessing it's slow because ArcMap is open. I'll show the code as it is now and the code that I'm trying to figure out a way for it to call an input directory/workspace rather than an mxd, but unfortunately it gets errors ('module' object has no attribute 'Listlayers').


# Import system modules
import arcpy
from arcpy import env


mxd = arcpy.mapping.MapDocument("CURRENT")

symbologyLayer = r"C:\VMshared\small_example_valley3\SnowColor2\snowdepthCOLOR.tif.lyr"

for lyr in arcpy.mapping.ListLayers(mxd):
arcpy.ApplySymbologyFromLayer_management(lyr,symbologyLayer)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...