Hi ,
i try to check if layer "openSpace" are in area coordinate with this code:
import arcpy from arcpy import env area= '178000 672000 190000 655000' 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] df.extent = area desc = arcpy.Describe(r"C:\Project\layers\openSpace.shp") if (map_Y_Max > layer_Y_max) and (map_X_Max > layer_X_max) and (map_Y_Min < layer_Y_min) and (map_X_Min < layer_X_min): print "layer is inside map extent" else: print "layer is outside map extent" mxd.save() del mxd
but i get an error:
>>> antiquities.mxd Traceback (most recent call last): File "C:\Users\yaron.KAYAMOT\Desktop\check if every layer in df extent_geonet.py", line 15, in <module> if (map_Y_Max > layer_Y_max) and (map_X_Max > layer_X_max) and (map_Y_Min < layer_Y_min) and (map_X_Min < layer_X_min): NameError: name 'map_Y_Max' is not defined >>>
i don't understand what my mistake because the layer extent is:
thanks for any help.
clever as it may be...those weren't assigned to his variables and the proper useage would be to parse the arguments from the extent in the first place
Sorry Dan,
just looked at the code...
Yes, where is all that Map_Y.... coming from!
Also I see his "extent" is a string, so that wouldn't work either.
Branching the "paste link" issue to here - Pasted links are not opening correctly so not to hijack this discussion.