7

I used python to update a shapeFile through cursors. The Shapefile is updated, but there could be an open Attribute Table.

Manually you can hit "reload cache" to update the Attribute Table and see the changes. I would like the python script to reload the cache, so the user does not have to remember to do this.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 1, 2012 at 22:52

2 Answers 2

2

Try the easy things first, like clearing and resetting the Layer's definition query or resetting its data source with the arcpy.mapping module. Failing that you could use ArcObjects in Python to refresh the table view via ITableWindow.Refresh.

answered Jun 2, 2012 at 1:13
1
  • I wonder if the arcpy.RefreshActiveView() would work in his script. Commented Jul 9, 2012 at 16:27
1

This works:

 import arcpy
 definition_query = layer.definitionQuery
 # Change the Definition Query into something different
 if definition_query == '':
 oid = arcpy.ListFields(dataset = layer, field_type = 'OID')[0]
 layer.definitionQuery = '{} > 0'.format(oid.name)
 else:
 layer.definitionQuery = ''
 arcpy.RefreshActiveView()
 # Restore the Definition Query
 layer.definitionQuery = definition_query
 arcpy.RefreshActiveView()
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Oct 27, 2016 at 13:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.