Enhanced version with automatic cleanup and object deduplication
Version 3 builds on Version 2 by adding two important features:
- Automatic Cleanup - Removes empty label lists created during import
- Rainfall Event Deduplication - Identifies and removes duplicate rainfall events by comparing actual data content
- 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
- 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
- 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)
✅ 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
The following object types cannot be deduplicated in Version 3 due to ICM API limitations:
- IWSW Time Patterns - The
exportmethod is not supported for this object type - IWSW Climatology - The
exportmethod 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.
After running this script, you'll have:
-
Individual Model Groups (one per scenario)
- Format:
[ModelName] - [ScenarioName] - Contains: Network, Rainfall Event, Selection List, Climatology, Time Patterns
- Clean: No empty label lists
- Format:
-
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)
- Format:
-
Log Files
- Location:
[ModelPath]/ICM Import Log Files/ - Master log with complete operation details
- Individual import logs for each scenario
- Location:
Run InfoSWMM_Import_with_Cleanup_UI.rb in InfoWorks ICM (Network > Run Ruby Script)
Browse to your InfoSWMM model file (.mxd)
- BASE scenario is automatically included
- Check additional scenarios you want to import
- Use "Select All" to import all scenarios
The script will:
- Import each scenario (with cleanup)
- Analyze and deduplicate Rainfall Events
- Create merged network
- Show summary dialog when complete
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
- 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
If a model group with the same name already exists in your database, the script will:
- Stop immediately with a clear error message
- Tell you which model group name conflicts
- 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.
| 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 | ❌ | ✅ | ✅ |
InfoSWMM_Import_with_Cleanup_UI.rb- UI script (run this one)InfoSWMM_Import_with_Cleanup_Exchange.rb- Exchange script (auto-launched)README.md- This fileVERSION 3 CHANGELOG.md- Detailed change historyOBJECT DEDUPLICATION.md- Technical details on deduplication
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 Filesfolder - Full stack traces for debugging
- User-friendly console messages
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
For issues or questions:
- Check the log files in
ICM Import Log Filesfolder - Review the Ruby output window for error details
- Refer to
OBJECT DEDUPLICATION.mdfor technical details
Version 3 - Final Release
Last Updated: January 2025