ModelBuilder...refresh map

2315
4
03-14-2013 02:30 PM
WesKing
New Contributor
Hi Everyone,
Apologies if this is not the correct forum.

In a model I've used 'Select Layer By Location' that has 3 parameters for the user to enter.  It is selecting features in a feature class that is in a Mapdocument.  It works great except the newly selected features do not show up in the .mxd as being selected (highlighted).  If you hit the refresh button then they appear as being selected.

Is there any way to include something in the model that causes an automatic refresh of the map?

Thanks in advance,
Wes
Tags (2)
0 Kudos
4 Replies
JonathanQuinn
Esri Notable Contributor
I've never come across a way to refresh the Table of Contents using ModelBuilder, but you could look into using Python and the RefreshActiveView function.  You could add the result of the Select By Location, but that'll just add a new layer with those selected features, so you'll have duplicate layers in the Table of Contents.
0 Kudos
WesKing
New Contributor
Thanks Jonathan,
I was hoping for something quick and easy (already available in ModelBuilder), but I know it's rarely that easy.

Thanks again for your response.

Wes
0 Kudos
TI
by
Occasional Contributor II

In Model Builder just add a 'Calculate Value' item to the model ( Insert -> Model Only Tools -> Calculate Value ).

Make sure this runs after all the parts of the model that affect map layers have completed by making one or more of them a precondition of the 'Calculate Value' item.

Open the 'Calculate Value' item and enter the Expression:  `arcpy.RefreshActiveView()`

The result of this calculate value item will actually be meaningless, but it will refresh the map.

General Note

The 'Calculate Value' tool in Model Builder is designed for using a script (or single line of code) to calculate some value to be used elsewhere in the model.

But you can ignore its output, and it turns out that it's really handy for simply running snippets of Python code to do anything in a model that you can do with Python that can't be easily done with other tools.

MarkFawkes
Occasional Contributor

I would never have thought of this totally obscure method. Seems to work well for me. And the idea of using this to run oher snippets of code within a model is something I will have to look into. Thanks to TasmanianIrrigation from sunny Brisbane!

0 Kudos