#Hec ras etc code
You’ll notice the code includes one subroutine called “ MonteCarloNValues” and if you scroll to the bottom you’ll see a Function called “ GetRandomNormal“. So, either you can go through the code and replace all accents (`) with apostrophes (‘), or just try copying the code from this text file instead. Visual Basic doesn’t recognize the accent. *If you have red font in the Visual Basic Editor, it is likely that the apostrophes (‘) before the comments were pasted in as accents (`). The code itself is in blue and black font. The comments are not actually part of the programming code, but are in there to help explain what each block of code does. They are made comments by putting an apostrophe (‘) in front of it. Note that the text in green font are comments. Your Visual Basic editor should now look like this: Now copy the code at the bottom of this post and paste it into the module. This will add a space for us to write and/or insert programming code. In the directory tree (usually this is docked in the upper left), right-click on VBAProject and select Insert…Module. If Excel recognizes you’ve used it before, it will sometimes move it to the top of the list. If you don’t see HEC River Analysis System in alphabetical order, check the top of the list. Click OK, and now you’ll have access to the HECRASController API. I’m going to use Version 5.0.7, so that’s the one I’ve selected. Make sure to only check the box for the version of HEC-RAS you wish to use. If you have multiple versions of HEC-RAS installed on your computer, you’ll see a reference here for each one. Scroll down until you see “HEC River Analysis System”. Add in the HECRASController as a reference in the “ Tools” menu item by selecting “ References…” The References window will show up like this: So if you have HEC-RAS on your computer, you already have the HEC-RAS API. The HECRASController API comes with the installation of HEC-RAS.
This will make it possible to do things like automatically open HEC-RAS, run HEC-RAS, change n-values, etc. This will give us access to the HECRASController program libraries for use in our code. Now let’s add in the HECRASController API as a reference to this project. The Visual Basic editor will open up and looks like this: Alternatively, you can use the shortcut keys Alt F11.
#Hec ras etc how to
Here’s a link that shows how to add the Developer Tab, if you don’t already have it on your ribbon. From the Developer menu item in Excel, select “Visual Basic”. In Excel, we’ll use the Visual Basic editor to write our automation code. Once you confirmed you can open up the Critical Creek project in HEC-RAS and you’ve spent some time getting familiar with it, go ahead and close HEC-RAS. You will be using the filename and path later in the code. For example, mine is C:\HEC-RAS Examples\Applications Guide\Chapter 1 – Critical Creek\CRITCREK.prj.
Make a note of the path and filename of the Critical Creek project on your computer. You’ll see this is a very simple 1D steady flow project. If you installed your example projects to the default directory, it will be here: C:\Users\\Documents\HEC Data\HEC-RAS\Example Data\Applications Guide\Chapter 1 – Critical Creek. Step 2: Open up the Critical Creek HEC-RAS example project. You’ll have to get that compressed file of example projects directly from the HEC website.
#Hec ras etc install
If you don’t have the compressed file of example projects that comes with the installation of HEC-RAS, you’ll get an error if you try to install them from the menu item. By default RAS will want to install these projects here: C:\Users\\Documents\HEC Data\HEC-RAS, but you can store them anywhere you like on your computer.