Skip To Content

Add Collapse Container By Attribute Rule


Adds a diagram rule to the rule list specified on a diagram template to automatically collapse all contents related to containers during diagram building. The containers with the contents to be collapsed are identified using a SQL query based on their attributes.

Learn more about the collapsing of containers in network diagrams


This tool is a configuration and administration tool that must be run by the database owner of the utility network through a direct connection to the default version. In addition to that requirement, the connected portal account must be the owner of the utility network to perform this operation. This essentially forms two-factor authentication.


  • The Collapse Container rule is used to simplify diagrams by collapsing all content related to containers that may exist in diagrams.

    This tool allows you to configure the Collapse Container rule to run by attributes. This means you can configure the collapse of diagram features of a particular container class by filtering the container features to collapse based on their attributes.


AddCollapseContainerByAttributeRule_un (in_utility_network, template_name, is_active, container_source, {where_clause}, {description}, {reconnected_edges_option})
ParameterExplanationData Type

The utility network referencing the diagram template to modify.

Utility Network

The name of the diagram template to modify.


Specifies whether the rule is enabled when generating and updating diagrams based on the specified template.

  • ACTIVEThe added rule becomes enabled during the generation and update of any diagrams based on the input template. This is the default.
  • INACTIVEThe added rule is not enabled during the generation or update of any diagrams based on the input template.

The network container source class that references the containers with the contents to be collapsed during the Collapse Container rule process.

Feature Class

An SQL expression used to select the subset of containers in this source class with the contents to be collapsed in the generated diagrams. For more information on SQL syntax, see SQL reference for query expressions used in ArcGIS.

SQL Expression

The description of the rule.


Specifies whether the rule must aggregate the edges that should be reconnected to the collapsed junctions or not.

  • DONT_AGGREGATE_RECONNECTED_EDGESAny edge connecting a content junction is kept and simply reconnected to the collapsed container junction.
  • AGGREGATE_RECONNECTED_EDGESAny edge connecting a content junction is replaced by a reduction edge that is reconnected to the collapsed container junction. Moreover, multiple edges between two collapsed junctions are systematically aggregated under the same reduction edge. This is the default.

Derived Output

NameExplanationData Type

The updated utility network.

Utility Network

The name of the network template.


Code sample

AddCollapseContainerByAttributeRule example (stand-alone script)

Add a Collapse Container By Attribute rule to the MyTemplate1 template to collapse contents in any structure junction containers that are not substation ASSETGROUP<>8 in the generated diagrams. This means any structure device container in the generated diagram will be collapsed except substation ASSETGROUP<>8.

import arcpy
input_UtilityNetwork = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.Electric"
input_DiagramTemplate = "MyTemplate1"
input_StructureDeviceToCollapse = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.StructureJunction"

arcpy.AddCollapseContainerByAttributeRule_un(input_UtilityNetwork, input_DiagramTemplate, 
                                             "ACTIVE", input_StructureDeviceToCollapse, 
                                             "ASSETGROUP <> 8", '', 'AGGREGATE_RECONNECTED_EDGES')


This tool does not use any geoprocessing environments.

Licensing information

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

Related topics