Skip to content

Instantly share code, notes, and snippets.

@sancarn
Last active February 5, 2018 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

1kmgrid

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

{G}{X3}{Y3}{C}

Node Naming

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

SU54602601
SU54602602
SU54602603
...

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=WSApplication.current_network
net.transaction_begin
    net.row_object("hw_prefs","geo_new_node_name_generator").memo = "Custom"
    net.row_object("hw_prefs","geo_new_node_name_generator").write
    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_layer").write
    net.row_object("hw_prefs","geo_new_node_name_gis_field").memo = "PLAN_NO"
    net.row_object("hw_prefs","geo_new_node_name_gis_field").write
net.transaction_commit

#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)
end

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.

Default_NodeNaming.rb
SPS_NodeNaming.rb
CSO_NodeNaming.rb
STW_NodeNaming.rb
...

Summary

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