Utility Network & ArcGIS Pro SDK 3.X: Create Association Fails Using ChainedEditOperation

145
0
03-27-2024 08:31 AM
sgn_GSI
New Contributor III

I have an add-in that loads and imports designs that can potentially contain hundreds of features and associations. The add-in performs an EditOp for each feature/association creation, logs the information, and chains the next EditOp along the process.

After upgrading the add-in to ArcGIS Pro SDK 3.2, the EditOperation is failing to create ALL associations. After significant testing, it appears that trying to create an association while passing in RowHandles, created in a different EditOperation scope, causes the association to fail.

Here is some psuedo-code to visualize the overall workflow of my add-in. It process all features first and then processes the associations.

 

QueuedTask.Run
    RowToken token = editOp.Create(structureJunctionLayer, poleAttributes);
    structureJunctionRowHandle = new RowHandle(token);
    editOp.Execute();
    editOp = editOp.CreateChainedOperation();
    token = editOp.Create(electricJunctionLayer, electricJunctionAttributes);
    electricJunctionRowHandle = new RowHandle(token);
    editOp.Execute();

QueuedTask.Run
    editOp = editOp.CreateChainedOperation()
    AssociationDescription assocDescr = new AssociationDescription(AssociationType.Attachment, structureJunctionRowHandle, electricJunctionRowHandle)
    editOp.Create(structAssocDescr);
    editOp.Execute();

 

The only way I've been able to successfully create the association is by creating both features and the association within the same scope of one edit operation.  As soon as I chain a new EditOp and attempt to create the association in a new scope, it fails. This is not an ideal solution for my add-in because the EditOperation error handling is abysmal. If I were to process hundreds of features and associations in one EditOp, it would be very difficult to debug if one particular feature/association is causing an issue.

What should be another possible solution would be to get the UtilityNetwork definition from the active map, and use that to generate new RowHandles within the same EditOp scope as the association creation. However, that does not seem to work in the ArcGIS Pro SDK 3.2 but works just fine in 2.X. Even when I create the point features, generate RowHandles from the UN, and create the association in one EditOp it will fail. This also is not an issue in the ArcGIS Pro SDK 2.X

Sample Code:

 

var networkSource = utilityNetwork.GetDefinition().GetNetworkSource("Structure Junction");
var assetGroup = networkSource?.GetAssetGroup("Electric Medium Voltage Pole");
var assetType = assetGroup?.GetAssetType("Single Pole");

var structElem = utilityNetwork.CreateElement(assetType, poleGlobalID);
var structRwHandle = new RowHandle(structElem, utilityNetwork);

networkSource = utilityNetwork.GetDefinition().GetNetworkSource("Electric Junction");
assetGroup = networkSource?.GetAssetGroup("Medium Voltage Attachment");
assetType = assetGroup?.GetAssetType("Overhead MV");

var attachElem = utilityNetwork.CreateElement(assetType, electricJunctionGlobalID);
var attachRwHandle = new RowHandle(attachElem, utilityNetwork);

 

Has anyone encountered a similar issue before and was able to come up with an alternate solution?

0 Kudos
0 Replies