# Get your Feature Layer extent layer = arcpy.mapping.Layer("Your Feature Layer") extent = arcpy.Describe(layer).extent # Create a Polygon object from that extent extentArray = arcpy.Array(i for i in (extent.lowerLeft, extent.lowerRight, extent.upperRight, extent.upperLeft, extent.lowerLeft)) extentPolygon = arcpy.Polygon(extentArray, arcpy.SpatialReference(4326)) del extentArray # Get reference to your dataframe mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "*")[0] # Whenever appropriate, test if the layerframe overlaps the extent geometry of your feature layer if df.extent.overlaps(extentPolygon) == False: layer.visible = False arcpy.RefreshActiveView() else: layer.visible = True arcpy.RefreshActiveView()
arcpy.mapping.ListLayers(mxd)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.