A neat Ruby script to delete all scenarios other than the base network

Within InfoWorks ICM, scenarios are a useful way of creating options, testing different network configurations and undertaking sensitivity analysis. However, once created and no longer needed, there is no easy way to delete them en masse. It is possible to delete them one by one using the ‘Manage Scenarios’ tool and it is also possible to write an SQL which deletes a list of multiple pre-defined scenarios.  Both of these approaches are time consuming.

There is a quicker, neater way of deleting all scenarios other than the base network by using Ruby Scripting within the user interface.  The ruby script will take the form of the below text:-


net.scenarios do |s|

                if s!=’Base’




The script is written in Ruby language within a text editor and needs to be saved as a file with extension type .rb.  Once this is created, you can open the network of choice and go to Network->Run Ruby Script and navigate to the location of the Ruby script.  This will then run the Ruby Script.  Once run, the Ruby script will appear within the list of recent scripts.  The Ruby script can also be associated with a custom action.

Ruby Scripting can be used within the user interface to manipulate data within the network, within the Open Data Import/Export Centres to filter and adjust import fields and also with ICM Exchange, the InfoWorks ICM API.  For more information on the Ruby scripting, particularly scripts that can be run within the InfoWorks ICM user interface then please contact the support team at support@innovyze.com.


Share this post!

    About Duncan Kitts

    Duncan Kitts is a Senior Support Engineer with Innovyze in the United Kingdom, specializing in River modelling and 2D modelling. He has over 9 years experience of modeling the key hydraulic processes involved in both fluvial systems and urban drainage environments. Duncan is responsible for providing support of both infoworks ICM and Infoworks RS.
    This entry was posted in ICMLive, InfoWorks ICM and tagged , , , , . Bookmark the permalink.