import os, sys, time import arcpy def main(): #make a layer from scratch tfc = 'c:/arcview/sf/forest/tract.shp' strmap = '4301' t = 'tracts' df = arcpy.AddFieldDelimiters(tfc, 'MAP') exp = df + " = '" + strmap + "'" result = arcpy.MakeFeatureLayer_management(tfc, t, exp) lyr = result.getOutput(0) # or get a layer from a .lyr file with the same def query lyrfile = 'c:/temp/tract.lyr' lyr2 = arcpy.mapping.Layer(lyrfile) #either of the next 2 lines bombs python, or crashes Arcmap if inside app ext = lyr.getExtent() ext2 = lyr2.getExtent() if __name__ == '__main__': main()
Solved! Go to Solution.