Skip To Content

Apply Relative Mainline Layout


Arranges the network diagram features in the active diagram along parallel straight lines.


  • This layout arranges the network diagram features in the active diagram along parallel straight lines, with all the connected edges having the same attribute value. It also places the branches from those lines, preserving their directions regarding the straight lines and the distances proportional to the initial distance and relative to each other.

  • This algorithm expects attributes with specific values on lines to type the lines and branches and prioritize or exclude certain lines, but it can also be applied to any data referencing lines that are parallel, even those originally designed for rail tracks.

  • Root flags can be set to specify the starting points of the junctions where the straight lines will start. If no root is set, the algorithm first searches junction candidates to be the root junctions—that is, junctions that are connected to a single edge that can be considered as the starting point for a straight line. Among those candidate junctions, the root junction will be the one that begins the longest straight line.


ApplyRelativeMainlineLayout_un (in_network_diagram_layer, line_attribute, {mainline_direction}, {offset_between_branches}, {breakpoint_angle}, {type_attribute}, {mainline_values}, {branch_values}, {excluded_values}, {is_compressing}, {compression_ratio}, {minimal_distance}, {alignment_attribute}, {initial_distances}, {length_attribute})
ParameterExplanationData Type

The network diagram where the layout will be applied.

Diagram Layer

The name of the network attribute that will be used to identify the lines that comprise the straight lines. This network attribute must exist in the utility network line classes. Its values should be the same for all the edges that comprise a straight line, for example, Line 1, Line 2, and so on


The direction of the main line

  • FROM_LEFT_TO_RIGHTThe main line will be drawn as a horizontal line starting from the left and ending on the right. This is the default.
  • FROM_TOP_TO_BOTTOMThe main line will be drawn as a vertical line starting from the top and ending at the bottom.

The spacing between two adjacent branches along the axis perpendicular to the direction of the lines.

Linear Unit

The angle that will be used to position the break point on the branches. It is a value between 30 and 90 degrees that is combined with the offset_between_branches parameter value to compute this position. When the break point angle value is 90 degrees, each branch displays orthogonally.


The name of the network attribute that will be used to qualify the lines. This network attribute may exist in the utility network line classes.


The type_attribute and line_attribute network attributes can be the same.


The type_attribute values that identify the main lines. When such values exist, they must be the same for any edge that comprises the main lines, regardless of their related utility network feature classes.

Value Table

The type_attribute values that identify the branches.

Value Table

The type_attribute values that identify the edges that must be excluded from the straight lines (crossovers or ladders).

Value Table

Specifies whether the graph will be compressed.

  • USE_COMPRESSIONAn additional step is executed at the end of the process to reduce the distances between adjacent groups of neighbor junctions along the direction while trying to maintain relative positioning between these groups. Neighbor junctions are junctions that are geographically close to each other without being directly connected.
  • DO_NOT_USE_COMPRESSIONCompression will not be used. This is the default.

A value between 0 and 100 that is applied to the length of any edge after subtracting the minimal distance of its length. When compression_ratio is 100, the distance between each detected junction group is equal to the minimal distance.


The minimal distance between two adjacent groups of neighbor junctions. This minimal distance is also used to group neighbor junctions regarding their projection along the direction axis. Two junctions projected on this axis will belong to the same group when the distance between the two projected points is less than this distance.

Linear Unit

The name of the network attribute that will be used to align lines that are split. The algorithm aligns the line with the same attribute value.


Specifies how the length of the diagram edges will be assessed. This length determines the positions of the junctions along the direction. The distances between the connected junctions along the direction are not equidistant; they are relative to each other and depend on the current edge length and the length of the shortest edge.

  • FROM_CURRENT_EDGE_GEOMETRY The distances will be computed from the current edge geometry. This is the default.
  • FROM_ATTRIBUTE_EDGEThe distances will be computed from a given attribute that exists on an edge.

The network attribute from which the distances will be computed when initial_distances is FROM_ATTRIBUTE_EDGE.


Derived Output

NameExplanationData Type

The updated network diagram.

Diagram Layer

Code sample

ApplyRelativeMainlineLayout example (Python window)

Apply the Relative Mainline Layout to Temporary diagram.

import arcpy
arcpy.ApplyRelativeMainlineLayout('Temporary diagram', 'LineTrack', 
                                  'FROM_LEFT_RIGHT’, 2, 45)


This tool does not use any geoprocessing environments.

Licensing information

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