6

Was trying to replicate a RePast Agent Analyst simulation using just Python and arcpy. The script was about urban expansion. The script just changes the values of a column in a shape file. ArcMap's symbology just color codes the parcels in the map based on the values of the mentioned column. The script just needs a way to refresh/reload the display for every step ( when the values in the column are changed ) of the simulation to show the user the changes.

I tried arcpy's RefreshActiveView but it doesn't work. Is there a way to to do it using arcpy? Or do I have to use ArcObjects for this?

2 Answers 2

7

The RefreshActiveView command should work for this, as far as I know. A quick few questions that might help troubleshoot:

Could you post a snippet of your .py in order to see which functions are running so we know what type of work is going on that is changing the values; this could have an effect on why it is not refreshing. Are you looking for the symbology to update due to the new values in the table?

ArcObjects could also be utilized in this scenario, but I prefer to not mix Objects and Python if possible because it has causes me a few issues in the past calling one from the other.

1
  • Still looking for my old code. Used UpdateCursor and SearchCursor to edit the values in the column. When I load the script from within the Python console, it crashes. I ended up using arcgisscripting and ArcGIS 9.3. When I run it by separately but with ArcMap open, it runs but the display in ArcMap won't refresh/reload.
    – R.K.
    Commented Jun 3, 2011 at 16:25
4

I've never run a cursor through arcpy in a running instance of ArcMap as you mention in the comment to MLowry's answer, but I would hazard a guess that if you simply want to refresh the display, you could perform an action using the mapping module. For instance, once creating a reference to the data frame in question, you could change the scale to a given value, which should trigger a redraw of whatever is in that active view (data frame). Alternatively, using the code to switch to Page Layout and back to Data View might also do the trick. It's hokey, but it might work for you.

2
  • Haven't used the mapping module. Thanks :D Will test it as soon as I get to the lab.
    – R.K.
    Commented Jun 7, 2011 at 4:28
  • 1
    You're gonna love the mapping module.
    – Roy
    Commented Jun 5, 2012 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.