Exporting Up to 99 HW Conduit Parameters to CSV with Ruby in InfoWorks ICM

Exporting Up to 99 HW Conduit Parameters to CSV with Ruby in InfoWorks ICM

Robert Dickinson

](https://www.linkedin.com/in/robertdickinson/)

Autodesk Water Technologist for Storm Sewer and Flood | Expert in ICM InfoWorks ICM SWMM/Ruby | 18 Years at Innovyze/Autodesk | 52 Years with EPASWMM TAC for CIMM.ORG SWMM5+

April 16, 2025

As part of our Ruby scripting series for InfoWorks ICM, this article shares a Ruby script to export hw_conduits data to a CSV file, simplifying data analysis for SWMM5 and ICM modelers. Learn how to use this script to streamline your workflow, with the code available on GitHub. Next, there will be articles for the sw_conduits (sw for SWMM) to a CSV file and then InfoWorks and SWMM to shape files. The grand goal is Ruby code for ALL 11,000 fields in ICM SWMM and ICM InfoWorks (as mentioned in other articles, InfoWorks has about three times more data fields). The ultimate goal is to improve how you use conduit data in your projects by using Ruby to manipulate the tables for export, comparisons, statistics, and AI.

1/ Introduction

This article is part of a series on using Ruby in ICM InfoWorks. The overall goal is to show how Ruby scripts can manipulate all 11,000 data elements in the SW and HW tables. The linked Ruby script in this one article provides code to select and export the hw_conduits table to a CSV file. Up to 99 conduit parameters can be exported.

2/ Why Use the Script?

The script allows you to extract specific data fields (e.g., pipe dimensions, IDs, or hydraulic properties) from the hw_conduits table, part of the 11,000 data elements in InfoWorks ICM’s SW and HW tables. The resulting timestamped CSV file is ideal for Excel analysis, reporting, or sharing with stakeholders. This Ruby script is only for hw tables as InfoWorks and SWMM conduit data are very different.

How different? Here is a comparison:

  • hw_conduits (InfoWorks ICM): Up to 99+ parameters, covering identifiers, hydraulic properties, asset metadata, sediment data, and more.
  • sw_conduits (SWMM5 in ICM): Approximately 10-15 parameters, focusing on basic geometry, roughness, and connectivity.

3/ How It Works

  • Connects to the active network in an ICM InfoWorks network.
  • Displays a dialog box to select an output folder and desired data fields (see Figure 1).
  • Iterates through selected hw_conduit objects, fetching user-specified data.
  • Writes the data to a timestamped CSV file, with error handling to ensure reliability (see Figure 4)

4/ Getting Started

  1. Open ICM and load your InfoWorks network model.
  2. Select the conduits you want to export using the built-in selection tools.
  3. Run the script (export_hw_conduit_data_to_csv.rb) via the ‘Run Script’ option.
  4. In the dialog box, choose your output folder and data fields, then click ‘OK.’
  5. Find the generated CSV in the specified folder.

5/ Where is the Code - the Autodesk Water Infrastructure GitHub

The script, export_hw_conduit_data_to_csv.rb, is available on the Autodesk Water Infrastructure GitHub repository under InfoWorks ICM/01 Ruby/02 SWMM/0005 - Import Export of Data Tables. Visit [GitHub link] to download the code and explore the detailed markdown documentation. 01 InfoWorks ICM/01 Ruby/02 SWMM/0005 - Import Export of Data Tables

Here is how the link fields are defined in the Ruby Script (snippet of the larger code)

# Define exportable fields
FIELDS_TO_EXPORT = [
['Include Pipe ID', :id, true, 'Pipe ID'],
['Include US Node ID', :us_node_id, false, 'US Node ID'],
['Include Link Suffix', :link_suffix, false, 'Link Suffix'],
...

Article content

Figure 1: Dialog for picking the link fields for export from the hw_conduits link table

Article content

Figure 2: The summary dialog tells you how many links and data fields are exported.

Article content

Figure 3: Ruby Puts Dialog Summary

Article content

Figure 4: End Result - Saved data for the HW Conduit Table in Excel for the selected elements

Closing Note

This script simplifies data export, saving time and enhancing your InfoWorks ICM workflow. Try it out, and share your feedback or questions in the comments!

Leave a Reply

Translate »
Scroll to Top

Discover more from SWMM5, ICM SWMM, ICM InfoWorks, Ruby and Vibe Apps, InfoSWMM, InfoSewer

Subscribe now to keep reading and get access to the full archive.

Continue reading