mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "my layer")[0] desc = arcpy.Describe(lyr.dataSource) df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] dfExtent = df.extent dfExtent.XMin = desc.extent.XMin dfExtent.XMax = desc.extent.XMax dfExtent.YMin = desc.extent.YMin dfExtent.YMax = desc.extent.YMax df.extent = dfExtent
I figured I would add this in case anyone else was interested, just another way to do it:
import arcpy, ast # Get feature set object from user input parameter extPoly=arcpy.GetParameter(0) # Read JSON property of the feature set as a dictionary jsonPoly=ast.literal_eval(extPoly.JSON) feat= (jsonPoly['features']) geom=((feat[0]['geometry']['rings'])) # Make separate list of x values and get min/max x listX = [] for coord in geom[0]: listX.append(coord[0]) minx = min(listX) maxx = max(listX) # Make separate list of y values and get min/max y listY = [] for coord in geom[0]: listY.append(coord[1]) miny = min(listY) maxy = max(listY)
This was my initial JSON return:
{
"displayFieldName":"",
"fieldAliases":{"OBJECTID":"OBJECTID","SHAPE_Length":"SHAPE_Length","SHAPE_Area":"SHAPE_Area"},
"geometryType":"esriGeometryPolygon",
"spatialReference":{"wkid":102643,"latestWkid":2227},
"fields":[{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID"},{"name":"SHAPE_Length","type":"esriFieldTypeDouble","alias":"SHAPE_Length"},{"name":"SHAPE_Area","type":"esriFieldTypeDouble","alias":"SHAPE_Area"}],
"features":[{"attributes":{"OBJECTID":1,"SHAPE_Length":898.13659879002444,"SHAPE_Area":48790.437030014538},
"geometry":{"rings":[[[6072538.7365812212,2099332.1891194731],[6072790.4726262987,2099361.7028399706],[6072792.2088433057,2099160.3141351491],[6072524.847829476,2099156.8417011499],[6072538.7365812212,2099332.1891194731]]]}
}]
}