Summary
Returns the names of all diagram templates related to a network.
Usage
This tool is not supported when working with a utility network or trace network service. You must use either a utility network or trace network in a file geodatabase or a database connection to a utility network or trace network in an enterprise geodatabase. When working with an enterprise geodatabase the following are requirements:
- The Input Network parameter value must be from a database connection established as the database utility network owner or database trace network owner.
- The connected ArcGIS Enterprise portal account must be the portal utility network owner or portal trace network owner.
- This tool must be connected to the default version, which is expected to be public and not protected.
This tool is mainly used to loop on diagram templates when running in ModelBuilder or Python.
Syntax
arcpy.nd.GetDiagramTemplateNames(in_utility_network)
Parameter | Explanation | Data Type |
in_utility_network | The utility network or trace network to which the diagram template names are related. | Utility Network; Trace Network |
Derived Output
Name | Explanation | Data Type |
out_template_names | The output diagram template names. | String |
Code sample
Export definitions of all diagram templates related to a given network.
The following script tool retrieves the list of the diagram templates related to a network and exports the definitions for each template into .ndbd and .ndld files in a given folder.
To add and configure this script tool, complete the following steps:
- Copy the following script into any Python IDE and save with the .py extension.
- Start ArcGIS Pro with a new blank project or an existing project.
- Add a new toolbox, or in the Catalog pane, click Project and use the default project toolbox under Toolboxes.
- Right-click this toolbox and click New > Script.
- Complete the General tab as follows:
- Name—Type ExportAllDiagramTemplateDefinitions.
- Label—Type Export All Diagram Template Definitions.
- Script File—Browse to and select the .py file created in step 1.
- Complete the Parameters tab as follows:
- 1st parameter
- Label—Type Input Network.
- Name—Keep the default name, Input_Network.
- Data Type—Select Utility Network and Trace Network.
- Type—Select Required.
- Direction—Select Input.
- 2nd parameter
- Label—Type Definition Files Export Folder.
- Name—Keep the default name Definition_Files_Export_Folder.
- Data Type—Select Folder.
- Type—Select Required.
- Direction—Select Input.
- 1st parameter
- Click OK. The Script Tool dialog box closes.
To run the script tool, complete the following steps:
- Expand the toolbox and double-click the tool to open it.
- Specify the Input Network parameter—that is, browse to and select the database connection file referencing the network from which you want to export all the template definitions,
- Specify the Output Folder parameter—that is, browse to and select the output folder where you want to export the template definition files.
- Click Run.
# Name: ExportAllDiagramTemplateDefinitions.py
# Description: Export definitions of all diagram templates related to a given network.
# Import system modules
import arcpy
import os
import re
# Initialize variables
msgInputsErr = "Invalid arguments."
msgScriptErr = "Error during script operation."
ndbd_ext = ".ndbd"
ndld_ext = ".ndld"
# Set overwrite option
arcpy.env.overwriteOutput = True
# Decodes parameters
try:
input_Network = arcpy.GetParameterAsText(0)
input_Folder = arcpy.GetParameterAsText(1)
if input_Network == "" or input_Folder == "" :
raise Exception()
except Exception:
arcpy.AddError(msgInputsErr)
raise
# Main code
try:
arcpy.AddMessage("Retrieving the templates list...")
output_TemplateNames = arcpy.GetDiagramTemplateNames_nd(input_Network)
templateNamesList = re.split(';', str(output_TemplateNames))
arcpy.AddMessage("Looping on each template...")
for template in templateNamesList:
message = "Exporting template: {}".format(template)
arcpy.AddMessage(message)
arcpy.ExportDiagramTemplateDefinitions_nd(input_Network, template,
os.path.join(input_Folder, template + ndbd_ext),
os.path.join(input_Folder, template + ndld_ext))
except Exception:
arcpy.AddError(msgScriptErr)
raise
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes