This Ruby script will change information stored within the ICM database, i.e. change values of your InfoWorks ICM network.
We start by telling Ruby to look at current network, calling this net.
We use the transaction_begin method, required when making changes to any table.
We apply the row_objects method, referring to ICM table hw_node to our current network. This value is assigned to a variable nodes. nodes now contains the table of nodes.
i=0 while i<nodes.length node=nodes[i] node.user_number_2=-123.45 node.user_text_2='caley_water_modified_by_ruby' node.write i=i+1 end
We create a loop and loop through all the items in our nodes table – i.e. all the nodes in the network. For every one we change the user_number_2 column and user_text_2 column. These column headers are effectively acting as methods in this case. We then use the method write, to overwrite the existing value with the one we have just defined.
Finally we use the transaction_commit method to end the transaction (which we started above with transaction_begin).
After running the script, if you open up your nodes table, you should see the values for user_number_2 and user_text_2 have changed for all nodes.