AnsweredAssumed Answered

set dataframe extents not working in arcpy

Question asked by danielbean on May 7, 2017
Latest reply on Aug 23, 2017 by timmo1982

I am unable to set the data frame extents to the extents of one layer. 


mxd = arcpy.mapping.MapDocument(r'C:\Projects\G25\MXD\G10001_Aspect.mxd')

df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]
print 'df Extent before:', df.extent

for lyr in arcpy.mapping.ListLayers(mxd, 'Outline'):
        lyr_extent = lyr.getExtent()
        print 'Layer Extent:', lyr_extent
        df.extent = lyr_extent
        print 'df Extent after:', df.extent
del mxd

The mxd df extent is not changed (extents printed below)

df Extent before: -48.7679994656522 -31.5306864013717 48.4338994650919 37.1648864006445 NaN NaN NaN NaN
Layer Extent: -10.5550864009008 -31.5306864013717 10.2209864003405 37.1648864006445 -0.86019999999553 0.806700000001001 NaN NaN
df Extent after: -48.7679994656522 -31.5306864013717 48.4338994650919 37.1648864006445 NaN NaN NaN NaN