Summary
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.
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.
Usage
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.
Syntax
CreateDiagram(in_utility_network, template_name, {features})
Parameter | Explanation | Data 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 to be used as input for diagram generation. | Feature Layer |
Derived Output
Name | Explanation | Data 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
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.MakeFeatureLayer_management(input_fc, "built_featurelayer",
sql_expression)
# Create a diagram based on a given template name from those features
result = arcpy.CreateDiagram_nd(input_network, template_name,
"built_featurelayer")
diagram_name = result[1]
arcpy.MakeDiagramLayer_nd(input_network, diagram_name,
"built_diagramlayer")
# Store the resulting diagram in the database.
arcpy.StoreDiagram_nd("built_diagramlayer", output_diagram_name)
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes