Problem using scripts to calculate fields in ArcPro Fabric Branched Versioning 3.0+

118
2
11-13-2022 12:47 PM
DeanAnderson2
Occasional Contributor

We use a lot of tools/scripts to calculate values within the ArcPro/Parcel Fabric Branched Version Environment (when it makes sense not to use tasks or calc attribute rules).   I am testing Version 3.0+ and have run into the following problem and am hoping that I may doing something wrong.  After a lot of testing I have created the following simple script that that illustrates the problem. (This all works fine in 2.94 and in a standard GeoDatabase). We do not use SDE for editing. 

Start State: Within Branched Version (GISADMIN.T67_9c_Test200Anno4) , Anno0200Scale feature class with Field (MapNumber) with value set to '6.3.8C').  

Proposed Process: Select OBJECTID = 7695 and Calc the value for MapNumber to be "XXXX" .  I have tested this using arcpy.da.Editor using UpdateCursor with the Source being: 

https://giscarts.co.polk.or.us/server/rest/services/PF/Parcel_Fabric_3/FeatureServer;VERSION=GISADMI...  which I calculate from the datasource of the Anno0200Scale feature class (after I removed the feature class name from the datasource text string).  

I have tested this without using the arcpy.da.Editor with da.UpdateCursor.  I have also tested this with a simple CalculateField both using the arcpy.da.editor and not using it.  

Problem:  I always get the same result.  NOTHING HAPPENS unless I close the ArcPro session and reopen it. Then I can see the change.  Using refresh screen / Change Version tool etc... None of it works.  Its like the edit did not happen until I close the session and then go back in.  My hope is that I am doing something wrong and somebody can help me out.  Below is the script (again this is not production just a test).  - it is also attached as a txt file.  Finally, within a simple edit session I can interactively select features and calculate attributes, see the results with no problem.  

import arcpy, os

# 1. Get parameter values

AnnoLayer = 'Anno0200Scale'

#2. Set Map Layers and default paths

thisProject = arcpy.mp.ArcGISProject("CURRENT")
Map = thisProject.activeMap
AnnoLyr = Map.listLayers(AnnoLayer)[0]
FolderPath = thisProject.homeFolder

arcpy.AddMessage ("Map: " + Map.name)
arcpy.AddMessage (AnnoLyr.dataSource)

datasource = AnnoLyr.dataSource
lastslash = datasource.rfind("/")
workspace = datasource[:lastslash]

arcpy.AddMessage(workspace)

MapNumber = 'XXXX'

# do edit session (Comment it out if you do not want to use it

edit = arcpy.da.Editor(workspace)
edit.startEditing(with_undo=False, multiuser_mode=True)
edit.startOperation()

with arcpy.da.UpdateCursor(AnnoLyr, ["MapNumber"],"OBJECTID = 7695") as cursor:
for row in cursor:
row[0] = MapNumber
cursor.updateRow(row)

edit.stopOperation()
edit.stopEditing(save_changes=True)

 

 

 

0 Kudos
2 Replies
AmirBar-Maor
Esri Regular Contributor

Hello @DeanAnderson2 

This looks to me like:

  1. An ArcGIS Pro refresh issue - the values are getting calculated but it requires closing and opening the ArcGIS Pro client to see the changes.
  2. A python issue when working against feature services.

My Advice:

  1. Since this is not specific to the parcel fabric, move this post to the ArcGIS Pro Questions https://community.esri.com/t5/arcgis-pro-questions/bd-p/arcgis-pro-questions and tag it appropriately so it reaches the right community.
  2. Open a case with technical support. It might be a known issue. If not - it should be.

Amir

0 Kudos
KenGalliher1
Esri Contributor

Hi Dean,

It would be nice if the Pro Mapping module had a refresh method for a current map or view object. This would make a great enhancement request.

We can hack a workaround using a selection and panning to the selection. I see in your UpdateCursor you are updating a specific feature. By using that feature's objectid, we can select it then pan to it. That should redraw the layers and show the edit.

# also get a map 'view' from the project
view = thisProject.activeView

with arcpy.da.UpdateCursor(AnnoLyr, ["MapNumber"], "OBJECTID = 7695") as cursor:
    for row in cursor:
        row[0] = MapNumber
        cursor.updateRow(row)
edit.stopOperation()
edit.stopEditing(save_changes=True)

# select the edited feature then pan to it
AnnoLyr.setSelectionSet([7695], "NEW")
view.panToExtent(view.getLayerExtent(AnnoLyr), selection_only=True)

 

Let me know if that helps.

 

Ken

0 Kudos