Select to view content in your preferred language

Adding Zoom to Selected feature to execute at the end of model.

16615
30
07-06-2010 10:24 AM
RyanFurlong
Regular Contributor
Greetings everyone, I work for a retailer and we have a shapefile of all our stores and they are individually ID'ed with a store number.  I have a very simple model that allows the user to input the store number and then the model selects it.  Ideally I would like the model to automatically zoom to the selected feature, right now I have to click the "zoom to feature" tool as a work around but I would like to not have to do that.  Do I have to write a custom scrip or is there an option I can just check in model builder?
0 Kudos
30 Replies
MarcTrinks
Deactivated User
Hi all,

So I have a model that selects parcels from a Feature Layer and buffers them by a user input distance...simple enough, works great.  I then have another model that is driven by a script that I found on the forums here that zooms to the selected features (code below).  Also works great when run as a stand alone model...it's when I try to drop this model into my main model that the map doesn't execute the zoom.  Script runs fine with no errors, but doesn't actually zoom in.

My question is that, since the "Zoom model" works as a standalone (i.e. after the features are selected and held in memory and the map document refreshes after the first model has run) can I kick off the second model after a pause/redraw/etc or is there something else I should be doing here?

import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()

Thanks in advance!
M
0 Kudos