Summary
Adds a diagram rule that automatically appends new network features to the diagrams based on their location relative to the network features currently represented in the diagram.
Learn more about using spatial query rules to build network diagrams
Caution:
This tool is a configuration and administration tool.
Note:
This tool impacts the consistency of any existing diagrams based on the input diagram template. All of the existing diagrams become inconsistent and open with a consistency warning icon until they are updated.
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.
The Spatial Query rule is used to detect new network features based on their location relative to network features that currently exist in the diagram, and append the newly detected features to the network diagram.
The network features with which the rule works are based on the same feature class, and those features can be filtered using an SQL query expression.
The appended network features are based on the same feature class, and those features can be filtered using an SQL query expression.
Syntax
arcpy.nd.AddSpatialQueryRule(in_utility_network, template_name, is_active, added_features, {overlap_type}, existing_features, {search_distance}, {added_where_clause}, {existing_where_clause}, {description})
Parameter | Explanation | Data Type |
in_utility_network | The utility network or trace network containing the diagram template to modify. | Utility Network; Trace Network |
template_name | The name of the diagram template to modify. | String |
is_active | Specifies whether the rule will be enabled when generating and updating diagrams based on the specified template.
| Boolean |
added_features | The source feature class to which features will be added. | Feature Class |
overlap_type (Optional) | The spatial relationship to be evaluated.
| String |
existing_features | The source feature class on which the spatial query will execute. | Feature Class |
search_distance (Optional) | The distance between features in the existing_features parameter and features in the added_features parameter. This parameter is only valid if the overlap_type parameter is set to INTERSECT, WITHIN_A_DISTANCE, CONTAINS, or WITHIN | Linear Unit |
added_where_clause (Optional) | The SQL query that will be used to filter the features to be added to the diagram. Without an SQL query, the features based on the specified source class that are spatially related to the specified existing features will be appended to the diagram. | SQL Expression |
existing_where_clause (Optional) | The SQL query that will be used to filter the features existing in the diagram. Without an SQL query, the features based on the specified source class that exist in the diagram will be considered. | SQL Expression |
description (Optional) | The description of the rule. | String |
Derived Output
Name | Explanation | Data Type |
out_utility_network | The updated utility network or trace network. | Utility Network; Trace Network |
out_template_name | The name of the diagram template. | String |
Code sample
Add a Spatial Query rule to the MyTemplate1 template to systematically add all subtransmission lines that intersect substations in the generated diagrams.
import arcpy
input_Network = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.Electric"
input_DistributionLine = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.ElectricDistributionLine"
input_StructureBoundary = "D:/MyProjectLocation/MyDatabaseConnection.sde/MyDatabase.MAP.Electric/MyDatabase.MAP.ElectricStructureBoundary"
input_DiagramTemplate = "MyTemplate1"
arcpy.AddSpatialQueryRule_nd(input_Network, input_DiagramTemplate,
'ACTIVE', input_DistributionLine, 'INTERSECT',
input_StructureBoundary, None, 'ASSETGROUP=6',
'ASSETGROUP=3')
Environments
Licensing information
- Basic: No
- Standard: Yes
- Advanced: Yes