Is there a way to refresh the data in a feature class's attribute table after running a standalone Python script?
Fully closing and re-opening ArcGIS Pro does accomplish this kind of refresh. But it would be very helpful to get it to refresh without having to close the program!
I'm using Pro 3.0.3 and cannot upgrade for a long time, due to my organization's needs relating to versions of License Manager, ArcGIS Server, existing map services and apps, etc.
I'm running a standalone Python script that edits attribute data in a feature class that's in an enterprise geodatabase. I am both editing and viewing the default, not a version. After running the script, the edits do not appear in Pro, unless I close and reopen the software. I have tried closing and reopening the attribute table, refreshing the data source in the Catalog pane (you'd think that would do it, but it does not), and panning/zooming the map in Pro. None of that makes the edits appear in the table. Any ideas?
Thank you!
Solved! Go to Solution.
There is an enhancement request in the Product Plan that's somewhat related to your question. ENH-000135306 - Implement a screen refresh when edits are made to features after a data access module is run in a Python script/tool in ArcGIS Pro." Hopefully soon!
There's the refresh button (2 blue arrows in a loop) at the top-right corner of the attribute table - does that not work? Removing and re-adding the data should work if that doesn't.
Thanks for your post!
Huh, I never knew about that refresh button, even though I have used Pro a lot! So thank you for pointing that out. Now, looking over to the right side near that button, I'm noticing the attribute table "hamburger" button, which I hadn't noticed either. I guess I'm used to buttons being aligned to the left side, so it feels odd to me to have most buttons aligned left but one or two aligned right. (And I have a huge screen, so that probably doesn't help with noticing buttons on an unexpected side.)
However, that refresh button at the bottom right of the map area didn't make the edits appear. It appeared to do some work, like the map area and table went white for a moment while it worked, and then they seemingly reloaded. But the edits still did not appear in the table. Next, to make sure there were indeed edits, I closed and reopened Pro, and then I could see the edits in the table.
[Edit: now I'm hunting on the screen for other buttons in places where I would not expect them, and I'm seeing another refresh button down at the bottom of the table, on the right, and the tooltip says "refresh the table." I had never even really noticed any of the buttons down there; I thought all the table buttons would be at the top left, maybe based on how ArcMap is? I'm going to do some testing now to see if this other button will do the job.]
Wow, I really thought that the refresh button at the bottom right of the attribute table would do the job, but it did not. Weird!
Actually, if you go to the data source panel, then right click to the database name and select "Refresh" it would work. But I'm also looking for an in-script solution to refresh it automatically.
If your script was associated with a tool in arctoolbox, then you would be better off since toolbox scripts are connected to the open Pro environment.
a Script tool would be the simplest
What is a script tool?—ArcGIS Pro | Documentation
If you have input parameters in your standalone script you can set them as defaults for the tool meaning that you can basically run the tool with preloaded parameters.
Thank you! Good to know. It's not worth it in this particular case to create a tool, but I guess it sounds like the implication is that a script is "disconnected" from Pro in such a way that refreshing the table doesn't grab the script's edits? That doesn't make sense to me... but Pro can be mysterious.
Jupyter notebooks launched from Pro, the python command line in Pro and toolbox scripts are all connected to Pro. A standalone script isn't although you can use arcpy and arctoolbox functionality.
the "arcgis" module might be worth a look but again it is geared to jupyter and suffers from some of the same limitations as standalone python scripts.
Add and remove a layer is a quick workaround that I have used when I get lazy
Thank you for the information!
I don't want to remove and re-add the layer in this case, since it has complex symbology. But that would be handy in many cases.
There is an enhancement request in the Product Plan that's somewhat related to your question. ENH-000135306 - Implement a screen refresh when edits are made to features after a data access module is run in a Python script/tool in ArcGIS Pro." Hopefully soon!