Utility-Data-Management-Support-Tools
Utility-Data-Management-Support-Tools copied to clipboard
Error: Executing from standalone Python
I get the following error while executing this code from Pycharm:
associationResult = arcpy.AssociationSelection_udms( in_utility_network=UN_NAME, layer_payload=layer_payload, # json_payload="""[ # { # "fromLayers": [], # "fromSelectionType": "KEEP", # "associationTypes": [], # "toLayers": [], # "toSelectionType": "NEW" # } # ]""" )
where UN_NAME is the path to my main UN network
Traceback (most recent call last):
File "D:\Delaporte\TIGRE\Sprint3_EPSEP\tigre-epsepare\main_epsepare.py", line 160, in
I did not find any information on the internet
I previously used a arcpy.ImportToolbox(UDMS_ATBS_PATH)
where UDMS_ATBS_PATH
stands for the path to the udms toolbox
In order for the selections in this tool to work, the UN (and its participating classes) must be in a map.
For your workflow, would it be acceptable if you had a saved Pro Project (aprx) with a map containing the UN? I think we could make this work, I'd need to investigate further.
I assume the tool works correctly when you run it from Pro?
It works perfectly fine in Pro and in toolboxes.
For your workflow, would it be acceptable if you had a saved Pro Project (aprx) with a map containing the UN? It would be acceptable, but how can we "link" this potential saved aprx into our standalone script in order to use UDMS ?
If you are scripting, you can use the internal class that the GP tool is calling. The function takes in an aprx and map name. We will look at exposing this in the GP tool `
import sys
atbx = r"C:\tools\UtilityDataManagementSupport.atbx"
sys.path.insert(0, atbx)
import udms
target_network = r"PathToUN"
pro_project = r"PathtoAPRX"
pro_map = "NameOfMapWithLayersToSelectInAPRX"
results = udms.logic.expand_selection(
utility_network=str(target_network),
payload=[
{
"fromLayers": ["Electric Distribution Device/Circuit Breaker"],
"fromSelectionType": "KEEP",
"associationTypes": [],
"toLayers": [],
"toSelectionType": "NEW",
}
],
project=pro_project,
map_name=pro_map,
)
I discussed with Paul. We need to update the code so you can access the project/map with the selection after the execution of the code. Right now, if you pass a project in, it is closed and not saved with the selection.