Zoom to Selected Features Tool for Model Builder

2471
3
04-08-2014 08:57 AM
Status: Open
MikePing
Occasional Contributor II
I would like to be able to create a geoprocessing service that selects a feature(s) and zooms to the selected feature(s).
3 Comments
DuncanHornby
This can be achived with a simple model and calling arcpy via the Calculate value tool as shown below.

0EME0000000TnRY
All the code in the Calculate tool is nothing more than:

import arcpy
def zoom():
  mxd = arcpy.mapping.MapDocument("CURRENT")
  df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
  df.zoomToSelectedFeatures()
  return True

With output set to type. Boolean.

MikePing
That works in ArcMap but it balks when you try to publish it as a geoprocessing service to be used in a web app.
JurateMeister

What bout ArcGIS Pro version?