Create Diagram (Network Diagram)

Summary

Creates a temporary network diagram from network features or network objects, or from trace locations currently specified in the active map.

Caution:

Edits must be saved so that the output diagram is in sync with the last save of the network topology in the database. Otherwise, the unsaved edits will not be reflected in the new diagram.

Learn more about creating network diagrams

Usage

  • By default, the Create diagram from trace locations parameter is unchecked and the tool searches for network features or network objects currently selected in the active map to use for the diagram creation. When run in a Python script and input layers are specified, the selection set in the map set will be ignored and the specified input layers are the only layers that will be used as input for the diagram creation.

  • To generate a diagram from trace locations, check the Create diagram from trace locations parameter. The tool will search for the starting points and barriers currently set in the network map to create the diagram. Any layers specified as feature input or network selection set existing in the map will be ignored. The trace locations currently specified in the map will be the only input used for the diagram creation.

  • The specified network layer, the selected network features and objects, or the specified trace locations can be from a utility network or trace network in a file or mobile geodatabase, a utility network service, or a database connection to a utility network in an enterprise geodatabase.

  • This tool creates a temporary diagram in the database. To access the diagram and use it with other tools, such as the Store Diagram tool, chain it with the Make Diagram Layer tool.

  • To generate a diagram from specific network features or network objects, you can run the Select tool or the Make Feature Layer and the Select Layer By Attribute tools before running this tool.

  • When this tool is set to operate from the selection set in the active network map, it processes both the network features selected in layers and network objects selected in nonspatial tables.

    However, nonnetwork elements that have been selected will not be included in the diagram. If only nonnetwork elements have been selected in the map, no output diagram will be created.

  • This tool will fail in the following situations:

    • There are dirty areas on network features selected in the active map.
    • There are dirty areas on container network features related to network objects selected in the nonspatial tables.
    In these cases, validate the network topology to clear the dirty areas and rerun the tool.

Parameters

LabelExplanationData Type
Input Network

The utility network or trace network from which the diagram will be created.

Utility Network; Trace Network; Utility Network Layer; Trace Network Layer
Input Template Name

The name of the template that will be used to create the diagram.

String
Features
(Optional)

One or more feature layers that will be used as input for diagram generation.

When feature layers are specified and network features or network objects are selected in the active map, the selection set is ignored and all the features in the specified layers are used as input for diagram creation.

When no feature layers are specified, the process searches for the network features and network objects selected in the active map and creates the diagram from this selection set.

This parameter can only be used when the Create diagram from trace locations parameter is unchecked.

Feature Layer
Create diagram from trace locations
(Optional)

Specifies whether the diagram creation will be processed from trace locations, or from network features and network objects.

  • Checked—The diagram creation will be processed from trace locations.
  • Unchecked—The diagram creation will be processed from network layers or from network features and network objects currently selected in the active map.

Boolean

Derived Output

LabelExplanationData Type
Output Network

The output utility network or trace network.

Utility Network; Trace Network; Utility Network Layer; Trace Network Layer
Network Diagram Name

The name of the network diagram.

String

arcpy.nd.CreateDiagram(in_utility_network, template_name, {features}, {is_created_from_trace_locations})
NameExplanationData Type
in_utility_network

The utility network or trace network from which the diagram will be created.

Utility Network; Trace Network; Utility Network Layer; Trace Network Layer
template_name

The name of the template that will be used to create the diagram.

String
features
[features,...]
(Optional)

One or more feature layers that will be used as input for diagram generation.

This parameter is ignored when the is_created_from_trace_locations parameter is set to CREATE_DIAGRAM_FROM_TRACE_LOCATIONS.

Feature Layer
is_created_from_trace_locations
(Optional)

Specifies whether the diagram creation will be processed from trace locations, or from network features and network objects.

  • CREATE_DIAGRAM_FROM_TRACE_LOCATIONSThe diagram creation will be processed from trace locations.
  • DO_NOT_CREATE_DIAGRAM_FROM_TRACE_LOCATIONSThe diagram creation will be processed from network features and network objects currently selected in the active map. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_utility_network

The output utility network or trace network.

Utility Network; Trace Network; Utility Network Layer; Trace Network Layer
out_name

The name of the network diagram.

String

Code sample

CreateDiagram example (stand-alone script)

The following stand-alone script demonstrates how to create a network diagram and store it in the database.

# Name: GenerateAndStoreADiagram.py
# Description:  Generate and store a diagram from a set of features based on a feature class and an attribute query.

# Import system modules
import arcpy

# Initialize variables
input_network = "https://cezembre.esri.com/server/rest/services/Naperville_Electric_SQL/FeatureServer/0"
input_fc = "https://cezembre.esri.com/server/rest/services/Naperville_Electric_SQL/FeatureServer/7"
sql_expression = "SUBNETWORKNAME='RMT003'"
template_name = "Basic"
output_diagram_name = "MyBasicRMT003Diagram"

# Set overwrite option
arcpy.env.overwriteOutput = True

# Make a layer from features in the feature class filtered out using an attribute query
FeatureLayer = arcpy.management.MakeFeatureLayer(input_fc, "built_featurelayer", 
                                                 sql_expression)

# Create a diagram based on a given template name from those features
result = arcpy.nd.CreateDiagram(input_network, template_name, 
                                "built_featurelayer")
diagram_name = result[1]
arcpy.nd.MakeDiagramLayer(input_network, diagram_name, 
                          "built_diagramlayer")

# Store the resulting diagram in the database. 
arcpy.nd.StoreDiagram("built_diagramlayer", output_diagram_name)

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics