Using the HEC-RAS Controller to Automate HEC-RAS

What is the HEC-RAS Controller?

The HEC-RAS Controller is part of the HEC-RAS application programming interface (API). An API is a collection of tools and protocols used in programming. The HEC-RAS API is comprised of three classes: the HEC-RAS Controller, HEC-RAS Flow, and HEC-RAS Geometry. The HEC-RAS Controller, which is the largest class of the HEC-RAS API, allows users to automate tasks such as data retrieval and post-processing output data. In addition, you can use the HEC-RAS Controller for statistical exercises like Monte Carlo Simulations. However, users can only apply the HEC-RAS API to one-dimensional (1D) problems. There are no functions available for HEC-RAS 2D models.

How do I access the HEC-RAS Controller?

If you have downloaded HEC-RAS, you have the HEC-RAS API! Users can access the HEC-RAS API using a variety of programming languages such as Python, R, and Visual Basic (VB). Many people use the Visual Basic Application (VBA) in Microsoft Excel. This has a couple of advantages. First, the engineering community uses Excel a lot; therefore, most people will be able to view your code/work. In addition, developers used VB to write the code behind HEC-RAS; therefore, the HEC-RAS API has a “VB” feel to it.

Although I have just promoted using Excl VBA quite heavily, I have used R to perform some functions in the HEC-RAS API. If you are interested in exploring some other programming languages, I recommend checking out this GitHub page. In addition, you might want to look into PyRAS by clicking here.

Opening the HEC-RAS Controller in Excel

    1. First, access the HEC-RAS API by opening the Excel Visual Basic Editor. You can do this by clicking Alt+F11 while in Excel. The Visual Basic Editor will open,
    2. Next, click Tools on the top menu. Then click References.
    3. Then select HEC River Analysis System from the Available References as shown below. If you have multiple HEC-RAS versions on your computer, you may see HEC River Analysis System listed several times. If this is the case, look at the bottom of the screen to determine which version you are selecting. After you have selected the appropriate version, click Ok.
    4. Next, click View on the top menu. Then click Object Browser. Alternatively, you can click the F2 button. Then select RAS506 from the libraries menu as shown below. If you have a different version of HEC-RAS, the library name will be slightly different. For example, the name will be RAS505 for HEC-RAS version 5.0.5.
    5. Finally, click around the Object Browser to see what subroutines and functions are available. Later, I will publish a post outlining the steps for writing a simple program using some of these procedures.

1 thought on “Using the HEC-RAS Controller to Automate HEC-RAS”

  1. Is it the hec-ras controller still does not work with 2D

Leave a Comment