Hi everyone,
I have 14 mxd's with scale 50000 and one mxd with scale 25000. with this code i try to add a new layer, extent to this layer then set a new scale 500000- just to mxd's with scale 50000 . i doesn't want to change the 25000 scale mxd, but i do want just to add him the new layer - and it doesn't work.
i don't know what wrong with this code- i think i didn't place the "if" statement in the right place:
import arcpy,os,sys
from arcpy import env
env.workspace = r"C:\Project"
lyr1 = arcpy.mapping.Layer(r"D:\PROJECTS\industryArad\gis\layers\4_11_15\GVUL TOHNIT.dwg Polyline.lyr")
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
if df.scale == 25000:
continue
arcpy.mapping.AddLayer(df, lyr1, "TOP") # TOP \ BOTTOM \ AUTO_ARRANGE
print 'AddLayer'
lyr = arcpy.mapping.ListLayers(mxd, "GVUL TOHNIT.dwg Polyline", df)[0]
ext = lyr.getExtent()
df.extent = ext
print 'getExtent'
df.scale = 500000
print df.scale
for lyr in arcpy.mapping.ListLayers(mxd, "bbb",df):
arcpy.mapping.RemoveLayer(df, lyr)
print 'remove'
mxd.save()
del mxd