It can be found here: http://ideas.arcgis.com/ideaView?id=087E00000004SmHIAU
Thanks everyone.
# Clip layers by extent of data frame (assuming in arcmap session) import os import arcpy from arcpy import env from arcpy import mapping mxd = mapping.MapDocument("CURRENT") df = mxd.activeDataFrame extent = df.extent
array = arcpy.Array() array.add(extent.lowerLeft) array.add(extent.lowerRight) array.add(extent.upperRight) array.add(extent.upperLeft) array.add(extent.lowerLeft) polygon = arcpy.Polygon(array, df.spatialReference) array.removeAll() del array for layer in mapping.ListLayers(mxd, data_frame=df): clipped_fc = env.scratchGDB + os.sep + layer.datasetName + "_clipped" arcpy.Clip_analysis(in_features=layer, clip_features=polygon, out_feature_class=clipped_fc) del layer del mxd del df del extent
>>> import random >>> random.seed() >>> print random.random() 0.884447776659 >>> print random.random() 0.379767969805 >>> print random.random() 0.580327390006
>>> random.randrange(start=0, stop=101, step=1) 52
>>> random.choice('abcdefghij') 'b'