Hi, I'm working on a script to programatically load Water Junction (taps), Water Line (service lines), and Water Device (meters) into a branch version within a water Utility Network.
The script uses the ArcGIS Python API to get the version from the Version Manager. It then uses the Version.edit() method to add new features to the version. Finally, it uses the Utility Network Manager's validate_topology() method to validate the entire UN.
The features are successfully loaded into the version and the dirty areas are removed from the newly added features, but the new features are not connected to the Utility Network and they are not returned in any trace results. They do seem to be connected to each other, however. For example, if you move one of the newly added meters, then the attached newly added service line will also move with it. Also, if I open ArcGIS Pro and move a tap away from a water main, re-attach it, and validate topology, then the tap, service line, and meter all become connected to the UN and are returned in trace results.
I'm wondering if there's some step or other GP tool that I need to run within the script, other than the topology validation, in order to make sure the newly added features are connected to the UN. Below are code samples of the adding of features and the topology validation done in the script. I may need to consult with ESRI on this, but figured that I'd try the forums first, to see if there's something glaring that I'm missing. Thanks!
Code sample: Adding features to branch version:
# Add meters
script.logger.info('Adding water devices')
meters_add_feature_set = arcpy.FeatureSet(new_meters_fc)
meters_add_feature_set_json = json.loads(meters_add_feature_set.JSON)
edit_layer = service_script_version.layers[water_device_layer_index]
service_script_version.mode = 'edit'
add_result = service_script_version.edit(layer=edit_layer, adds=meters_add_feature_set_json['features'])
number_successful_adds = 0
for entry in add_result['addResults']:
if entry['success'] is True:
number_successful_adds += 1
script.logger.info('Number of features successfully added: ' + str(number_successful_adds))
script.logger.info('Stopping editing and saving edits')
service_script_version.stop_editing(save=True)
Code sample: Validating topology:
# Validate topology
service_script_version = version_manager.get(version_name)
service_script_version.mode = 'edit'
script.logger.info('Getting utility network from version')
utility_network_manager = service_script_version.utility
script.logger.info('Validating Network Topology')
validation_envelope = {"xmin": 2944897.7434605407,
"ymin": 9969206.089035971,
"xmax": 3210005.065902318,
"ymax": 10211905.345106306,
"spatialReference": {"wkid": 102739,
"latestWkid": 2277}
}
validation_result = utility_network_manager.validate_topology(envelope=validation_envelope)
script.logger.info('Validation result: ' + str(validation_result))
service_script_version.stop_editing(save=True)