4

I have problem with my script. Layers are in one geodatabase, and have names like: orne1942, orne 2003, orne 2009 (the same forpart e.g. orne). Script should changing symbology layers wich have the same forpart (uniform it) in many map documents (.mxd). Mayby someone have idea what I am doing wrong ? (I am just begning my python adventure.... )

my script:

import arcpy
path = (r"C:\program2_D.Nowak\map\\")
arcpy.env.workspace=path
arcpy.env.overwriteOutput=True
orneWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\orneWZOR.lyr")
for mapDoc in arcpy.ListFiles("*.mxd"):
   print mapDoc
   mxd=arcpy.mapping.MapDocument(path + mapDoc)
   print mxd
   df=arcpy.mapping.ListDataFrames(mxd, "*")[0]
   for df in arcpy.mapping.ListDataFrames(mxd):
        orne=arcpy.mapping.ListLayers(mxd, "orne*", df)[0]
        arcpy.mapping.UpdateLayer(df, orne, orneWZOR)
   mxd.save()
   print "done"
del mxd
del lasyWZOR, drogiWZOR, orneWZOR, odlogowaneWZOR, zabudowaneWZOR, laki_pastwiskaWZOR <
  • Are you receiving an error message? If so, can you include that in your question, please? – PolyGeo Jan 31 '13 at 22:03
1

My script start working :) Thanks :)

# Importing arcpy
import arcpy
# Set Local Variables
path = (r"C:\program2_D.Nowak\map\\")
# Set environment setting
arcpy.env.workspace=path
arcpy.env.overwriteOutput=True
#Set template layers from .lyr files
lasyWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\lasyWZOR.lyr")
drogiWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\drogiWZOR.lyr")
orneWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\orneWZOR.lyr")
odlogowaneWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\odlogowaneWZOR.lyr")
laki_pastwiskaWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\laki_pastwiskaWZOR.lyr")
zabudowaneWZOR=arcpy.mapping.Layer(r"C:\program2_D.Nowak\zabudowaneWZOR.lyr")
# lisy of mxd files in folder - path 
for mapDoc in arcpy.ListFiles("*.mxd"):
print mapDoc
mxd=arcpy.mapping.MapDocument(path + mapDoc)
print mxd
#Set Local Variables 
df=arcpy.mapping.ListDataFrames(mxd, "*")[0]
# list of Data Frames in map documets
for df in arcpy.mapping.ListDataFrames(mxd):
    #Set Local Variables 
     lasy=arcpy.mapping.ListLayers(mxd, "lasy*", df)[0]
     #Update layers symbology in map documents 
     arcpy.mapping.UpdateLayer(df, lasy, lasyWZOR)
     orne=arcpy.mapping.ListLayers(mxd, "orne*", df)[0]
     arcpy.mapping.UpdateLayer(df, orne, orneWZOR)
     zabudowane=arcpy.mapping.ListLayers(mxd, "zabudowane*", df)[0]
     arcpy.mapping.UpdateLayer(df, zabudowane, zabudowaneWZOR)
     drogi=arcpy.mapping.ListLayers(mxd, "drogi*", df)[0]
     arcpy.mapping.UpdateLayer(df, drogi, drogiWZOR)
     odlogowane=arcpy.mapping.ListLayers(mxd, "odlogowane*", df)[0]
     arcpy.mapping.UpdateLayer(df, odlogowane, odlogowaneWZOR)
     laki_pastwiska=arcpy.mapping.ListLayers(mxd, "laki_pastwiska*", df)[0]
     arcpy.mapping.UpdateLayer(df, laki_pastwiska, laki_pastwiskaWZOR)
#Save a map document  
mxd.save()
print "done"
# clear variable references
del mxd
del lasyWZOR, drogiWZOR, orneWZOR, odlogowaneWZOR, zabudowaneWZOR, laki_pastwiskaWZOR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.