Monday, January 26, 2015

HECRASController VBA Code-Companion to “Breaking the HEC-RAS Code”

Written by Christopher Goodell, P.E., D.WRE  |  WEST Consultants
Copyright © The RAS Solution 2015.  All rights reserved.

There has been a lot of demand from new owners of the book “Breaking the HEC-RAS Code” for example code in VBA form.  So…here it is!  Aside from the obvious fact that you wont have to re-type code from the book into your own Excel VBA modules, this Excel Workbook provides the benefit of seeing how each and every procedure in the HECRASController works.

 image
That’s right, every subroutine, and every function are documented in this workbook, along with example code from a wide range of HEC-RAS automation procedures and some code snippets for error catching and string manipulation-very important when reading/writing HEC-RAS input files.  In total, there are over 150 procedures and over 8000 lines of code for you to use for help while you create your own HEC-RAS automation projects.


Each procedure from the HECRASController is demonstrated in either a subroutine or function in this Excel Workbook.  Each demonstration provides up-front commentary including the procedure's name, what it does, cautions and pitfalls to look out for, as well as what standard HEC data set it was tested with (i.e. Bald Eagle Creek, Beaver Creek, etc.). 


image
There’s also commentary all throughout each demonstration so that you’ll know exactly what each block of code does.  

The HECRASController VBA Code Excel Workbook will make a valuable companion to “Breaking the HEC-RAS Code”.  Every bit of code presented in the book is available in digital form in the Excel Workbook.  The HECRASController VBA Code is optimized for Version 5.0 of HEC-RAS. It will work right now with the current beta release, and will work with the official version when it is released.  

The HECRASController VBA Code Excel Workbook is available here:



6 comments:

  1. Seriously? I was fine paying $85 for the book, but now you're charging $60 for an Excel spreadsheet with some macros?

    ReplyDelete
    Replies
    1. That's quite the comment "Anonymous". First of all, thank you for buying the book, but no one made you buy it and no one is making you buy the HECRASController Code workbook. If you don't think there is value in it, don't buy it. Second, it sounds like you don't have an appreciation for how much work was spent putting it together. It's not a "few" macros. It's every HECRASController procedure plus many other examples. Over 150 in all. I'd be happy to talk with you more on the concept of intellectual property and basic principles of economics if you like. Otherwise, please make your own Excel workbook coding and documenting every single HEC-RAS controller and then give it away without any compensation for the work you put into it. Good luck.

      Delete
    2. Sorry, I get it, and I really do appreciate the work you've done here. It's just frustrating that these major features have been undocumented (at least publicly) for so long. I'm glad there's finally something available.

      Delete
    3. No worries. And I understand the frustration too. That's the primary reason I began this project 5 years ago.

      Delete
  2. Hi Chris, we have an Hec-ras model with all cross-sections. We would like to add in bridges and culverts (a great number of them). Can we use HECRAScontroller to insert bridges and culverts by write a code? if so, do you have examples in your companion excel workbook for a quick start?

    ReplyDelete
    Replies
    1. Yes, you can use the Edit_AddBC procedure. However, for RAS to save the newly created Bridge or culvert, you have to make some kind of edit to it inside of HEC-RAS. Therefore, it might be easier just to write code that automatically inserts your bridges and culverts directly into the Geometry input text file. Chapter 4 in “Breaking the HEC-RAS Code” discusses in detail how to write to the geometry text file. Also, the Geometry Input File Keys presented in Appendix B will be of tremendous help to you. I don’t have sample code on hand that does this, but it shouldn’t be difficult to write. Write code to progress through the geometry input file. When you get between two existing river stations where you want to insert a bridge, have the code construct the bridge/culvert input structure at that location in the text file.

      Delete