Font size

Railway network

The rail yard topology is specified by specific space markup shapes designed for rail models: railway tracks, switches, and elements defining offsets on the track (Position on track). These shapes can be either drawn manually using AnyLogic graphical editor or created programmatically by e.g. reading the layout from a database or a file.

Railway network is automatically created when you create a railway track. It can be extended by connecting more tracks together.

Please refer to Railway track for more information about drawing and connecting tracks.

The Rail Library will not automatically detect track crossings (i.e. places where two tracks cross each other without a switch) and it is the user’s responsibility to make sure there are no train collisions in such places, whereas collisions at switches are detected automatically and errors are signaled.

To change railway network parameters

  1. Click on any markup shape belonging to the railway network. The shape will be selected.
  2. Click on this shape again to select the entire railway network.
  3. Proceed to the Properties view and modify the railway network’s parameters.



Name — The name of the railway network. The name is used to identify and access the network from code and flowchart blocks properties.

Ignore — If selected, the network is excluded from the model.

Visible on upper agent — If selected, the network is also visible on the upper agent where this agent lives.

Lock — If selected, the network is locked. Locked shapes do not react to mouse clicks — it is impossible to select them in the graphical editor until you unlock them.

Visible — Here you specify whether the network shapes are visible on animation at model runtime, or not. Using the control, choose yes or no.

Level — Level to which this railway network belongs.


Show in — Here you can choose whether you want the shape to be shown both in 2D and 3D animation, or in 2D only, or in 3D only.


Function Description
List<RailwayTrack> getTracks() Returns the list of tracks belonging to this railway network.
List<RailwaySwitch> getSwitches() Returns the list of switches belonging to this railway network.
List<PositionOnTrack> getPointOnTracks() Returns the list of Position on Track elements belonging to this railway network.
double getZ() Returns the Z-coordinate of the railway network’s base level.
boolean isVisible() Returns true if the railway network is visible; returns false otherwise.
void setVisible(boolean v) Returns true if the railway network is visible; returns false otherwise.

v — visibility. If v is true — the railway network is set to be visible, if it is false — not visible.
Level getLevel() Returns the level this railway network belongs to.
How can we improve this article?