Trace2Config

Title  Trace to Trace Configurations

Description

Converts arcpy.un.Trace to arcpy.un.ImportTraceConfigurations

Usage

          
To capture the python code, configure a Utility Network trace and copy the python command.
If the name of the trace configuration already exists, a number will be appended for uniqueness.

License

Standard

Toolset

Utility Network

Syntax

Trace2Config (trace_configurations, execute, {output_script})

Parameter Explanation Data Type
trace_configurations Dialog Reference

The Trace Configurations to create.

  • Python - The python code for Trace.
  • Name - The name of the trace configuration that will be created.
  • Description - A short description of the trace. This is optional.
  • Tags - Keywords used during search. Enter multiple tags on newlines. This is optional.

GPValueTable
execute Dialog Reference

Option to immediately add the configurations

  • Checked - Add the trace configurations.
  • Unchecked - Generate the call to add the trace configuration in the file specified. This is the default.

GPBoolean
output_script (Optional) Dialog Reference

Creates the trace configuration JSON file to be used in arcpy.un.ImportTraceConfigurations.

DEFile

Code Samples

Trace2Config example 1 (Python window)

Converts arcpy.un.Trace to arcpy.un.AddTraceConfiguration

import arcpy

arcpy.udms.Trace2Config(
    [
        [
            r"""arcpy.un.Trace(
    in_utility_network=\"d:/data/Electric_UtilityNetwork.gdb/UtilityNetwork\Network\",
    trace_type=\"UPSTREAM\",
    starting_points=None,
    barriers=None,
    domain_network=\"Electric\",
    tier=\"Electric Distribution\",
    target_tier=\"\",
    subnetwork_name=\"\",
    shortest_path_network_attribute_name=\"\",
    include_containers=\"INCLUDE_CONTAINERS\",
    include_content=\"INCLUDE_CONTENT\",
    include_structures=\"INCLUDE_STRUCTURES\",
    include_barriers=\"INCLUDE_BARRIERS\",
    validate_consistency=\"VALIDATE_CONSISTENCY\",
    condition_barriers=\"\'E:Operating Status Normal\' IS_EQUAL_TO SPECIFIC_VALUE 1 OR;\'E:Operating Status Normal\' IS_EQUAL_TO SPECIFIC_VALUE 2 OR;\'Lifecycle Status\' DOES_NOT_INCLUDE_ANY SPECIFIC_VALUE 6 OR;Category IS_EQUAL_TO SPECIFIC_VALUE E:Ground OR;Category IS_EQUAL_TO SPECIFIC_VALUE \'E:Open Point\' #\",
    function_barriers=None,
    traversability_scope=\"BOTH_JUNCTIONS_AND_EDGES\",
    filter_barriers=None,
    filter_function_barriers=None,
    filter_scope=\"BOTH_JUNCTIONS_AND_EDGES\",
    filter_bitset_network_attribute_name=\"\",
    filter_nearest=\"DO_NOT_FILTER\",
    nearest_count=None,
    nearest_cost_network_attribute=\"\",
    nearest_categories=None,
    nearest_assets=None,
    functions=None,
    propagators=\"\'E:Phases Propagated\' \'E:Phases Substitution\' PROPAGATED_BITWISE_AND INCLUDES_ANY 7\",
    output_assettypes=None,
    output_conditions=None,
    include_isolated_features=\"EXCLUDE_ISOLATED_FEATURES\",
    ignore_barriers_at_starting_points=\"DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS\",
    include_up_to_first_spatial_container=\"DO_NOT_INCLUDE_UP_TO_FIRST_SPATIAL_CONTAINER\",
    result_types=None,
    selection_type=\"NEW_SELECTION\",
    clear_all_previous_trace_results=\"CLEAR_ALL_PREVIOUS_TRACE_RESULTS\",
    trace_name=\"\",
    aggregated_points=\"Trace_Results_Aggregated_Points\",
    aggregated_lines=\"Trace_Results_Aggregated_Lines\",
    aggregated_polygons=\"Trace_Results_Aggregated_Polygons\",
    allow_indeterminate_flow=\"TRACE_INDETERMINATE_FLOW\",
    validate_locatability=\"DO_NOT_VALIDATE_LOCATABILITY\",
    use_trace_config=\"DO_NOT_USE_TRACE_CONFIGURATION\",
    trace_config_name=\"\",
    out_json_file=None,
    run_async=\"RUN_SYNCHRONOUSLY\",
    include_geometry=\"EXCLUDE_GEOMETRY\",
    include_domain_descriptions=\"EXCLUDE_DOMAIN_DESCRIPTIONS\",
    result_network_attributes=None,
    result_fields=None
)""",
            "Upstream: Distribution",
            "An upstream trace in the distribution tier.",
            "electric, distribution",
        ]
    ],
    "ADD_CONFIGS",
    "d:/data/tc_out.py",
)

Trace2Config example 2 (stand-alone script)

Converts arcpy.un.Trace to arcpy.un.AddTraceConfiguration

import arcpy


arcpy.udms.Trace2Config(
    trace_configurations=[
        [
            r"""arcpy.un.Trace(
    in_utility_network=\"d:/data/Electric_UtilityNetwork.gdb/UtilityNetwork\Network\",
    trace_type=\"UPSTREAM\",
    starting_points=None,
    barriers=None,
    domain_network=\"Electric\",
    tier=\"Electric Distribution\",
    target_tier=\"\",
    subnetwork_name=\"\",
    shortest_path_network_attribute_name=\"\",
    include_containers=\"INCLUDE_CONTAINERS\",
    include_content=\"INCLUDE_CONTENT\",
    include_structures=\"INCLUDE_STRUCTURES\",
    include_barriers=\"INCLUDE_BARRIERS\",
    validate_consistency=\"VALIDATE_CONSISTENCY\",
    condition_barriers=\"\'E:Operating Status Normal\' IS_EQUAL_TO SPECIFIC_VALUE 1 OR;\'E:Operating Status Normal\' IS_EQUAL_TO SPECIFIC_VALUE 2 OR;\'Lifecycle Status\' DOES_NOT_INCLUDE_ANY SPECIFIC_VALUE 6 OR;Category IS_EQUAL_TO SPECIFIC_VALUE E:Ground OR;Category IS_EQUAL_TO SPECIFIC_VALUE \'E:Open Point\' #\",
    function_barriers=None,
    traversability_scope=\"BOTH_JUNCTIONS_AND_EDGES\",
    filter_barriers=None,
    filter_function_barriers=None,
    filter_scope=\"BOTH_JUNCTIONS_AND_EDGES\",
    filter_bitset_network_attribute_name=\"\",
    filter_nearest=\"DO_NOT_FILTER\",
    nearest_count=None,
    nearest_cost_network_attribute=\"\",
    nearest_categories=None,
    nearest_assets=None,
    functions=None,
    propagators=\"\'E:Phases Propagated\' \'E:Phases Substitution\' PROPAGATED_BITWISE_AND INCLUDES_ANY 7\",
    output_assettypes=None,
    output_conditions=None,
    include_isolated_features=\"EXCLUDE_ISOLATED_FEATURES\",
    ignore_barriers_at_starting_points=\"DO_NOT_IGNORE_BARRIERS_AT_STARTING_POINTS\",
    include_up_to_first_spatial_container=\"DO_NOT_INCLUDE_UP_TO_FIRST_SPATIAL_CONTAINER\",
    result_types=None,
    selection_type=\"NEW_SELECTION\",
    clear_all_previous_trace_results=\"CLEAR_ALL_PREVIOUS_TRACE_RESULTS\",
    trace_name=\"\",
    aggregated_points=\"Trace_Results_Aggregated_Points\",
    aggregated_lines=\"Trace_Results_Aggregated_Lines\",
    aggregated_polygons=\"Trace_Results_Aggregated_Polygons\",
    allow_indeterminate_flow=\"TRACE_INDETERMINATE_FLOW\",
    validate_locatability=\"DO_NOT_VALIDATE_LOCATABILITY\",
    use_trace_config=\"DO_NOT_USE_TRACE_CONFIGURATION\",
    trace_config_name=\"\",
    out_json_file=None,
    run_async=\"RUN_SYNCHRONOUSLY\",
    include_geometry=\"EXCLUDE_GEOMETRY\",
    include_domain_descriptions=\"EXCLUDE_DOMAIN_DESCRIPTIONS\",
    result_network_attributes=None,
    result_fields=None
)""",
            "Upstream: Distribution",
            "An upstream trace in the distribution tier.",
            "electric, distribution",
        ]
    ],
    execute="ADD_CONFIGS",
    output_script="d:/data/tc_out.py",
)