// Create a subnetwork named "Mesh1" from three controllers
// elementM1, elementM2, and elementM3 represent the devices that serve as subnetwork controllers (e.g., network protectors)
subnetworkManager.EnableController(lowVoltageMeshTier, elementM1, "Mesh1", "M1", "my description", "my notes");
subnetworkManager.EnableController(lowVoltageMeshTier, elementM2, "Mesh1", "M2", "my description", "my notes");
Subnetwork subnetworkMesh1 = subnetworkManager.EnableController(lowVoltageMeshTier, elementM3, "Mesh1", "M3", "my description", "my notes");
subnetworkMesh1.Update();
MapView.Active.Redraw(true);
// ...
// When deleting the subnetwork, each controller must be disabled before the subnetwork itself is deleted
subnetworkManager.DisableControllerInEditOperation(elementM1);
subnetworkManager.DisableControllerInEditOperation(elementM2);
subnetworkManager.DisableControllerInEditOperation(elementM3);
// After the subnetwork is deleted, all of the rows that have been labeled with the subnetwork ID need to be updated
subnetworkMesh1.Update();
MapView.Active.Redraw(true);
// The final step is to notify external systems (if any) by exporting the subnetwork
SubnetworkExportOptions subnetworkExportOptions = new SubnetworkExportOptions()
{
SetAcknowledged = true,
IncludeDomainDescriptions = true,
IncludeGeometry = true,
ServiceSynchronizationType = ServiceSynchronizationType.Asynchronous,
SubnetworkExportResultTypes = new List<SubnetworkExportResultType>()
{
SubnetworkExportResultType.Features
}
// Set networks attributes and attribute fields to export
//ResultNetworkAttributes = new List<NetworkAttribute>(networkAttributes),
//ResultFieldsByNetworkSourceID = new Dictionary<int, List<string>>()
// { { electricDevice.ID, new List<string>() { "AssetID" } } }
};
subnetworkMesh1.Export(new Uri($"{Path.GetTempPath()}SubnetworkExportResult.json"), subnetworkExportOptions);