Skip to content

Instantly share code, notes, and snippets.

Last active February 5, 2018 10:57
Show Gist options
  • Save sancarn/91e4fcb8c64fdb57e2950a59064f4067 to your computer and use it in GitHub Desktop.
Save sancarn/91e4fcb8c64fdb57e2950a59064f4067 to your computer and use it in GitHub Desktop.
InfoWorks ICM - Node naming defaults with Ruby

InfoWorks ICM - Node naming defaults with Ruby

Many water companies provide guidelines to their consultants/staff defining how to name dummy nodes in a hydraulic model. This gives the water company full leverage over the hydraulic model externally and keeps data organised. However, for the most part, these conventions are easy to talk about but difficult to remember...

A hydraulic modeller often doesn't get payed for searching through the, often verbose, documentation on model building to find what they should use while naming their nodes. Instead, they often choose one standard and stick with it. To make the modeller's lives a little easier we can build a 'model build' ruby script library/add-on. Something which provides functionality which is so useful a modeller is insentifised to use it. In such a library we can include our node-naming conventions.

Custom node naming defaults

A well known feature of ICM is that you can automatically generate node names following a selected format.

Node Naming

One little known feature however, is that you can fully customise this to fit your needs using GIS layers. For example, let's say you have a GIS zone layer open named 1_km_Grid. In my case, this is the Ordanance Survey 1km grid


Now, I'll set the pattern to the following:


Node Naming

Whenever I create a new node using these settings I get a model node like:


Node naming conventions suite

Though this is common knowledge, I think few people know that you can automate the process of setting the node naming conventions. You can do so with Ruby, however I assume you can also do so with SQL as well but I have not yet figured out how.

Ruby example

In ruby we can take it one step further by also checking whether the layer the modeller needs open, is indeed open:

    net.row_object("hw_prefs","geo_new_node_name_generator").memo = "Custom"
    net.row_object("hw_prefs","geo_new_node_name_pattern"  ).memo = "{G}{X3}{Y3}{C}    
    net.row_object("hw_prefs","geo_new_node_name_pattern"  ).
    net.row_object("hw_prefs","geo_new_node_name_gis_layer").memo = "[SHP] 1_km_Grid"
    net.row_object("hw_prefs","geo_new_node_name_gis_field").memo = "PLAN_NO"

#Check whether the layer is currently open, if so it should be in MapXtremeLayers
layers = WSApplication.current_network.row_object("hw_prefs","MapXtremeLayers").Memo
path = 'I:\Tools\JW\Resources\1_km_Grid.shp'
if layers.index(path) ==nil
    WSApplication.input_box("Please open the following table.","Layer not open.",path)

The above script can be altered to work with different assets and each ruby script compiled into an ICM-Addon for each node naming convention.



Special node naming conventions are great but give your modeller's the tools they need to do it easily!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment