Skip to content

SWMMEnablement/Hackathon_KM

Repository files navigation

InfoSWMM Multi-Scenario Import - Version 3 with Cleanup

Enhanced version with automatic cleanup and object deduplication

Overview

Version 3 builds on Version 2 by adding two important features:

  1. Automatic Cleanup - Removes empty label lists created during import
  2. Rainfall Event Deduplication - Identifies and removes duplicate rainfall events by comparing actual data content

What This Script Does

Phase 1: Individual Scenario Import

  • Imports each selected scenario into a separate model group
  • Each model group is named: [ModelName] - [ScenarioName]
  • Automatically cleans up empty label lists after each import

Phase 1.5: Object Deduplication Analysis

  • Analyzes all imported Rainfall Events across all scenarios
  • Compares actual rainfall data (not just names) to identify true duplicates
  • Prepares list of unique objects for the merged network

Phase 2: Merged Network Creation

  • Creates a master network from the BASE scenario
  • Copies only unique Rainfall Events to the merged group
  • Adds all other scenarios as ICM scenarios under the master network
  • Removes inactive elements from each scenario (based on selection lists)

Key Features

Clean Database - No empty label lists cluttering your model groups
Smart Deduplication - Only keeps unique Rainfall Events (compares data, not names)
Proper ICM Scenarios - All scenarios in one network for easy comparison
Optimized Storage - Removes duplicate objects to save space
Error Handling - Graceful failure with clear error messages
Detailed Logging - Complete logs saved to ICM Import Log Files folder

Known Limitations

Objects That Cannot Be Deduplicated

The following object types cannot be deduplicated in Version 3 due to ICM API limitations:

  • IWSW Time Patterns - The export method is not supported for this object type
  • IWSW Climatology - The export method is not supported for this object type

These objects will be copied with the BASE network and may result in duplicates in the merged model group. This is a limitation of the InfoWorks ICM Ruby API, not the script.

Impact: If you have scenarios with identical time patterns or climatology settings, they will appear as separate objects in the merged network even if they contain the same data.

Workaround: After import, you can manually review and consolidate duplicate time patterns and climatology objects in the ICM UI.

What You Get

After running this script, you'll have:

  1. Individual Model Groups (one per scenario)

    • Format: [ModelName] - [ScenarioName]
    • Contains: Network, Rainfall Event, Selection List, Climatology, Time Patterns
    • Clean: No empty label lists
  2. Merged Model Group (all scenarios combined)

    • Format: [ModelName] - Merged Scenarios
    • Contains: One master network with all scenarios
    • Optimized: Only unique Rainfall Events included
    • Note: May contain duplicate Time Patterns/Climatology (API limitation)
  3. Log Files

    • Location: [ModelPath]/ICM Import Log Files/
    • Master log with complete operation details
    • Individual import logs for each scenario

How to Use

Step 1: Launch the Script

Run InfoSWMM_Import_with_Cleanup_UI.rb in InfoWorks ICM (Network > Run Ruby Script)

Step 2: Select Model File

Browse to your InfoSWMM model file (.mxd)

Step 3: Select Scenarios

  • BASE scenario is automatically included
  • Check additional scenarios you want to import
  • Use "Select All" to import all scenarios

Step 4: Wait for Completion

The script will:

  • Import each scenario (with cleanup)
  • Analyze and deduplicate Rainfall Events
  • Create merged network
  • Show summary dialog when complete

Step 5: Review Results

Check the Ruby output window for detailed summary including:

  • Number of scenarios imported
  • Number of label lists cleaned up
  • Number of Rainfall Events deduplicated
  • Log file location

Requirements

  • InfoWorks ICM (tested with 2024-2026 versions)
  • InfoSWMM model file (.mxd)
  • BASE scenario in the model (recommended, but not required)
  • No existing model groups with the same names in the database

Duplicate Name Handling

If a model group with the same name already exists in your database, the script will:

  1. Stop immediately with a clear error message
  2. Tell you which model group name conflicts
  3. Prompt you to delete or rename the existing group

To run the script again: Delete or rename any existing model groups created by previous imports.

Comparison with Previous Versions

Feature Version 1 Version 2 Version 3
Individual model groups
Merged network
Cleanup empty label lists
Deduplicate Rainfall Events
Scenario data preserved
Inactive elements removed

Files

  • InfoSWMM_Import_with_Cleanup_UI.rb - UI script (run this one)
  • InfoSWMM_Import_with_Cleanup_Exchange.rb - Exchange script (auto-launched)
  • README.md - This file
  • VERSION 3 CHANGELOG.md - Detailed change history
  • OBJECT DEDUPLICATION.md - Technical details on deduplication

Error Handling

The script includes robust error handling at every stage:

Pre-flight Validation:

  • Validates all required configuration keys are present
  • Verifies the .mxd file exists and is accessible
  • Confirms file extension is correct (.mxd)
  • Checks database connection before starting

Phase 1 Protection:

  • If an individual scenario import fails, the script continues with remaining scenarios
  • All errors are logged but don't stop the whole process

Phase 2 Protection:

  • If the merged network creation fails, individual model groups remain intact
  • Any partial merged network is automatically cleaned up
  • Clear messages explain which phase succeeded and which failed

Detailed Logging:

  • All operations logged to ICM Import Log Files folder
  • Full stack traces for debugging
  • User-friendly console messages

Troubleshooting

Script doesn't start

  • Make sure you're running the UI script (not the Exchange script)
  • Check that InfoWorks ICM is properly installed

"Configuration file not found" error

  • Run the UI script, not the Exchange script directly
  • If problem persists, check write permissions in the model folder

"Duplicate Model Group" error

  • Delete existing model groups with the same names
  • Or rename them (e.g., add " - Old" to the end)

Missing scenarios

  • Ensure scenarios exist in the InfoSWMM model
  • Check that SCENARIO.DBF file exists in the .ISDB folder

Scenarios imported but all data is the same

  • This is likely an InfoSWMM issue, not the script
  • Verify scenarios have different data in InfoSWMM

Duplicate Time Patterns or Climatology in merged network

  • This is expected due to API limitations
  • Manually consolidate duplicates in ICM UI if needed

"File does not exist" error

  • The .mxd file may have been moved or deleted
  • Ensure the file path is correct and accessible

Support

For issues or questions:

  1. Check the log files in ICM Import Log Files folder
  2. Review the Ruby output window for error details
  3. Refer to OBJECT DEDUPLICATION.md for technical details

Version 3 - Final Release
Last Updated: January 2025

About

Hackathon_KM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages