AnsweredAssumed Answered

Zoom to layer

Question asked by yaron148 on Sep 18, 2014
Latest reply on Sep 18, 2014 by yaron148

I have a problem with the getExtent function on  arcpy

I try to focus on  layers that start with letters "ra" and then sets the scale of 50000. i try to use asterisk (*) but the code does not work

import arcpy, os, sys

from arcpy import env



env.workspace = r"C:\Project"

for mxdname in arcpy.ListFiles("*.mxd"):

    print mxdname

    mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)

    df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

    lyr = arcpy.mapping.ListLayers(mxd, "*ra", df)[0]

    ext = lyr.getExtent()

    df.extent = ext

    print 'getExtent'

    df.scale = 50000

    print 'scale'

del mxd


Any help will be appreciated.