Ruby Script

Running a Ruby script can help automate the editing of a network in InfoWorks ICM.

You can use the Ruby script editor to view and edit a Ruby script, to validate its syntax and to run the script in a network.

Tip: You can use the require_relative command to reference other Ruby scripts in the same Model or Live group in a single Ruby script. When you run the Ruby script, all referenced scripts are also run.

See Working with Database Items for details about creating, opening, importing and exporting a Ruby script and other relevant database item functions, and Introduction to Ruby Scripting in InfoWorks for general information about Ruby scripting in InfoWorks ICM.

Running Ruby scripts

Ruby scripts can be run in the current network in the GeoPlan by:

All Ruby scripts in the same Model or Live group, are automatically exported to your local working folder as RB files when a script is run.

If the Ruby script is run successfully, a Script output window is displayed, listing the changes that have been applied. An example is shown below:

If it is not run successfully, a message is displayed, which indicates the likely error and the name of the folder the failed Ruby script file is exported to.

Tip: You can use the Edit menu's Undo option to revert any changes applied to the network from a Ruby script. If the changes were applied from multiple Ruby scripts or a single script that referenced other scripts, all changes are reverted.

Ruby version and compatibility

InfoWorks ICM uses Ruby 3.4.6 to run scripts:

  • Some behaviour from earlier Ruby versions is no longer supported. Scripts created with earlier Ruby versions may not run as expected and may require updates.
  • Some functionality previously provided by the Ruby standard library may now be delivered via RubyGems.
  • External libraries can be installed and used through RubyGems.

Test existing scripts under Ruby 3.4.6 and update them if required.

Gems can be installed programmatically using the RubyGems API (for example, using Gem.install). Install gems only from trusted sources.

For information about Ruby language changes and migration, refer to the official Ruby documentation: