Create Diagram (Network Diagram)


Creates a temporary network diagram from network elements currently selected in the active map or from layers created from a Python script.

When layers are specified and there are elements selected in the active map, the selected elements set is ignored and the specified input layers are the only layers used as input for the diagram creation.

When no layers are specified, the tool searches for the network elements selected in the active map and creates the diagram from those elements.


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


  • The network layer or network data element specified for the input network parameter can be from a utility network or trace network in a file 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 elements, you can execute the Select tool or the Make Feature Layer and the Select Layer By Attribute tools prior to running the Create Diagram tool.

  • This tool can operate on network features selected in layers and network objects selected in nonspatial tables that are referenced in the input map.

    Any nonnetwork elements that have been selected will not be included in the diagram. If only nonnetwork elements have been selected, an output diagram will not be created.

  • The Create Diagram tool fails 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 reexecute the tool.


CreateDiagram(in_utility_network, template_name, {features})
ParameterExplanationData Type

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

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

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


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

Feature Layer

Derived Output

NameExplanationData Type

The output utility network or trace network.

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

The name of the network diagram.


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:
# 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 = ""
input_fc = ""
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.MakeFeatureLayer_management(input_fc, "built_featurelayer", 

# Create a diagram based on a given template name from those features
result = arcpy.CreateDiagram_nd(input_network, template_name, 
diagram_name = result[1]
arcpy.MakeDiagramLayer_nd(input_network, diagram_name, 

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


This tool does not use any geoprocessing environments.

Licensing information

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

Related topics