I see that I'm not the first person who can't get map layers to refresh/redraw after feature geometries have been modified. I have an addin that updates the geometry and attributes of selected features. The attribute updates are immediately visible in the attribute table, but geometry updates are not, unless I save edits, and then close and re-open Pro.
I've tried:
MapView.Active.Redraw(true)
and:
myFeatureLayer.SetDataConnection((CIMFeatureDatasetDataConnection)myFeatureLayer.GetDataConnection())
I'm using Pro 3.3, and myFeatureClass's data connection (Json) is:
{
"type": "CIMFeatureDatasetDataConnection",
"featureDataset": "GDB_HMSDev.HMSADMIN.KerrySandbox",
"workspaceConnectionString": "ENCRYPTED_PASSWORD_UTF8=00022e684a474377616152656c6f7a763650316344487555664e68764d523255577766652b50366a714e7457374c343d2a00;ENCRYPTED_PASSWORD=00022e68385049416956586c766d4f566e64316f46466a4367764b4e443157626e374a494d4c624641786b466543343d2a00;SERVER=aotgis;INSTANCE=sde:sqlserver:aotgis;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=aotgis;DATABASE=GDB_HMSDev;USER=HMSADMIN;VERSION=sde.DEFAULT;AUTHENTICATION_MODE=DBMS",
"workspaceFactory": "SDE",
"dataset": "GDB_HMSDev.HMSADMIN.Nodes_1",
"datasetType": "esriDTFeatureClass"
}
Here's the Edit Operation code, and I can provide the rest of the addin code if necessary. Any Suggestions?
// Edit Operation
var updateDangleNodeAndLegShapes = new EditOperation() { Name = "Add Node and Legs" };
// Modify Node
nodeInspector["SHAPE"] = newNode;
nodeInspector["NodeClass"] = "testing_addin";
// Modify NodeLeg
var newLeg = SharedMethods.makeLeg(singlePolyline, startEnd);
var legInspector = new Inspector();
legInspector.Load(legsMapMember, selectedFeatures[legsMapMember].First()); // This works because only one nodeLeg is selected
legInspector["SHAPE"] = newLeg;
updateDangleNodeAndLegShapes.Modify(nodeInspector);
updateDangleNodeAndLegShapes.Modify(legInspector);
if (!updateDangleNodeAndLegShapes.IsEmpty)
{
var result = updateDangleNodeAndLegShapes.Execute(); //Execute will return true if the operation was successful and false if not.
if (result)
{
MapView.Active.Redraw(true); // doesn't refresh
nodesMapMember.SetDataConnection((CIMFeatureDatasetDataConnection)nodesMapMember.GetDataConnection()); // doesn't refresh
legsMapMember.SetDataConnection((CIMFeatureDatasetDataConnection)legsMapMember.GetDataConnection()); // doesn't refresh
MessageBox.Show(string.Format("Features modified"));
}
else
{
MessageBox.Show("Feature not created. Error: {0}", updateDangleNodeAndLegShapes.ErrorMessage);
}
}
In case this makes a difference: My workflow for using the addin is to edit a feature in one feature layer manually using the EditVertices tool, and then I select features from two other feature layers, and execute my addin button to edit those selected features.
Thanks for any insight! 🙂