Written by Chris Goodell, P.E., D.WRE | WEST Consultants
Copyright © The RAS Solution 2014. All rights reserved.
Are you an HEC-RAS user? Yes? OK, try this out:
1. If you haven’t already done so, install the HEC-RAS example projects to the default location.
2. Open up a blank workbook in Excel.
3. Press Alt-F11. When the Visual Basic Editor Window opens up, select Tools…References…
4. Scroll down until you see HEC River Analysis System. If you see more than one “HEC River Analysis System”, that means you have more than one version of HEC-RAS installed on your computer. That’s okay, just select the one for the version of HEC-RAS you want to use. Check the box and click OK.
5. Click Insert…Module. Then in the module editor that pops up type (or copy and paste) the following code. In the line that starts with strRASProject = “C:\Users…, make sure to use your User Name, not cgoodell. The directory path should match where you’ve installed the HEC-RAS example projects. Also, only include the last line, HRC.QuitRAS, if you are using HEC-RAS Version 5.0 or higher. If you are using Version 4.1 or lower, omit this line of code.
Sub RunRAS()
'Instantiate a new HECRASController Class
Dim HRC As New HECRASController
'Open a new project.
Dim strRASProject As String
strRASProject = "C:\Users\cgoodell\Documents\HEC Data\HEC-RAS\Steady Examples\BEAVCREK.prj"
HRC.Project_Open strRASProject
'Run the HEC-RAS Project
Dim lngMessages As Long
Dim strMessages() As String
HRC.Compute_CurrentPlan lngMessages, strMessages()
'Get water surface elevations at Node 5
Dim sngWSElev As Single
sngWSElev = HRC.Output_NodeOutput(1, 1, 5, 0, 1, 2)
MsgBox "The water surface elevation is " & sngWSElev & "."
'Close HEC-RAS. The following line is only needed for HEC-RAS Version 5.0.
HRC.QuitRas
End Sub
6. Click Run…Run Sub/UserForm, or just press F5, and watch what happens. If you get the following error message (or similar), make sure you typed in the HEC-RAS project path and filename correctly and that you actually do have a project located there. Remember to replace “cgoodell” with your computer User name in the strRASProject definition in the code.
If you see HEC-RAS compute and then get the following message, then congratulations…it worked!
There. You’ve just run your first HECRASController application! Let me know in the Comments below if it worked for you. There is so much more you can do with the HECRASController. Automation of HEC-RAS projects, specific output data retrieval, batch mode simulations, real time modeling, Monte Carlo simulations, to name a few. As you’ve just found out, if you have HEC-RAS, you already have the HECRASController.
You can learn more about using the HECRASController in my new book, "Breaking the HEC-RAS Code." Get your copy today!
.
This is great. Are there libraries to run in .NET as well or only vba?
ReplyDeleteYes, you can do this in .NET also. I just like to demonstrate it in VBA, since most everyone has Excel. Thanks.
DeleteChris, this is great..
ReplyDeleteLooking forward to see the book in few weeks.
Thanks! I'll keep you posted.
DeleteWorked for me as well. Thanks Chris. Looking forward to the book.
ReplyDeleteCan I perform these using R-programming or Python....
ReplyDeleteI think so. Give it a try and let me know if it works.
DeleteDid this ever work for you Anonymous? I'm considering trying both just for the heck of it but I don't want to if you've already found out it can't work...
DeleteJoshua-I've had some users email me about their attempts at using R for the RASController with some success. If you send me your email address, I can forward it on and maybe you can collaborate directly? Just a thought.
DeleteHi Chris, at the moment I am attempting to use R to automate HEC-RAS. It has been difficult to find any documentation or previous experience on this subject. Could you please share with me some information so I can use it as a guide and probably collaborate?
DeleteHi Chris, sorry for the late reply. My email is joshua/.cal/eb.ste/ele@/gmail.com (remove the slashes), feel free to forward me onto whoever.
ReplyDeleteI'm having almost no trouble getting it working in Excel, but I want to be better versed in R than I am too so it couldn't hurt.
Hi Joshua- did you ever have success with automating HEC-RAS within R? I have found it difficult to find information on this and any advice you have would be appreciated!
DeleteHi Chris,
ReplyDeletebeing in a need to autmate HEC-RAS launching I tested your example and it worked well for me - so well that ordered the book. However being in a hurry, let me please ask a question:
- do you have any Java API/library for the HEC-RAS Controller ?
- are there any hints in the book how to launch HEC-RAS and collect the results without Excel ?
Thanks in advance
Martin
Martin-Thanks for getting the book! To answer your questions, the API should work with Java, as long as your Java programming platform can reference the HECRASController. But, I have not tried that. If you get it to work, please let me know. Although the book is written around using the HECRASController in VBA (Excel), it does discuss briefly how to get it set up in Visual Studio. I imagine the procedure is similar in other platforms.
DeleteGood luck. Let me know how it goes!
Chris
Hi Chris,
ReplyDeleteI am using the Excel to run my project (1 river, 1 reach, 35 river stations for 24 hours - 13AUG2015 0000 - 14AUG2015 0000).
However I cannot get the stage output values for the respective hours of simulation:
- the attempt to get the data from DSS file by the call:
HRC.OutputDSS_GetStageFlow rivers(1), reaches(1), strRS(6), nValue, dateTimes(), stage(), flow(), errmsg
results in nValue=25, correct dateTimes however with error message:
No records were found (the data returned all -902's)
No records were found (the data returned all -902's)
However when I run the project in HEC-RAS GUI, I can see in the DSSFile the records with the data:
/MORAVA DOLNY TOK//LOCATION-FLOW//13AUG2015 0000/FALOSNA/
...
/MORAVA DOLNY TOK//LOCATION-FLOW//13AUG2015 2400/FALOSNA/
and I can see stage data for all 35 RS for any particular time chosen.
The calsl like Ouput_NodeOutput are probably of no use since I cannot get the data for all times, just the final value, or am I missing something ?
Thanks in advance.
Martin
please post your code here so I can see what is going on.
DeleteHi Chris,
ReplyDeleteI am still trying to automate the HEC-RAS - we need to run it on Windows machine from Linux one via ssh.
I have the VBS script alunching an Excel file as well as Excel makro doing the HEC-RAS calculations.
The problem is, that when I run the VBS script by command
cscript C:\IMS\bin\models\runHECRAS.vbs c:\IMS\bin\models\project2.xls d:\Shares\data-model02\HEC_RAS_Morava
from Windows Power Shell locally, I can see starting Excel as background process in Task Manager, HEC-RAS starts either as Background process or as App as I can see in Task Manager (anyway very strange behaviour), I can see the HEC-RAS Window open, calculations are performed and everything works as it should.
When I run the command over ssh:
ssh root@10.40.152.2 cscript "c:\\IMS\\bin\\models\\runHECRAS.vbs" "c:\\IMS\\bin\\models\\project2.xls" "D:\\Shares\\data-model02\\HEC_RAS_Morava"
the command starts, I can see starting Excel as background process in Task Manager, HEC-RAS starts as Background process but gets stuck.
Logs from the Excel makro show, that the call which gets stuck is:
Dim HRC As New HECRASController
The macro stops and must be terminated manually, no error can be obtained.
This may be a sort of security issue - the FreeSshd however runs as service under Local System Account and is allowed to interact with desktop.
I wonder, if you have any sort of hint how to enable starting HEC-RAS from system service (I found in the book none).
Any help would be appreciated.
Martin
Martin- That is some advanced stuff. I really don't know anything about ssh and I'm afraid I don't know what is going on with your situation. I will forward this on to someone I know that may be able to help and I'll let you know if I get anything useful for you.
DeleteChris
Martin,
DeleteI am working on a project very similar to yours. I am trying to execute Ras models on remote machines but instead of using excel and a macro I am using a python script that takes parameters through command line the parameters are the .prj, .p01, etc. I see hec-ras open on the Task Manager but like your issue it stalls. I am using c# to access the remote machines through PsExec adn write the command line script. Any guidance on getting the models to run would be great! Thanks!
Chris,
ReplyDeletejust more information: running VBS script via ssh / cscript with starting of Excel but without access to HECRASController works well - the Excel starts, the macro produces expected output to log files, Excel finishes.
The real problem is in HECRASController.
Is there any debug mode in HEC-RAS which can be activated by me to see when and where it gets stuck ?
Because being stuck, I cannot access even any Error from VBA in Excel.
Martin
Unfortunately Martin, there is no debug mode for the HECRASController. I'm still waiting to hear back from HEC on your issue. Hopefully they'll have a useful workaround.
DeleteChris
Chris,
ReplyDeleteI found the workaround by wrapping cscript command to Windows scheduled task and launching schtasks command via ssh. It worked automatically until some changes in User accounts on Windows have been introduced.
Now I am facing very strange problem:
- when launching the HEC-RAS via Excel directly using cscript command, everything is OK and the HEC-RAS produces output files including project.dss:
----------+ 1 matog None 32000 2016-01-27 14:24 project.IC.O01
----------+ 1 matog None 384000 2016-01-27 14:24 project.O01
----------+ 1 matog None 3348 2016-01-27 14:24 project.b01
----------+ 1 matog None 2840 2016-01-27 14:24 project.bco01
----------+ 1 matog None 27916 2016-01-27 14:24 project.c01
----------+ 1 matog None 558592 2016-01-27 14:24 project.dss
----------+ 1 matog None 258915 2016-01-27 14:24 project.g01.hdf
----------+ 1 matog None 208 2016-01-27 14:24 project.p01.blf
----------+ 1 matog None 344203 2016-01-27 14:24 project.p01.hdf
----------+ 1 matog None 60190 2016-01-27 14:24 project.r01
----------+ 1 matog None 43292 2016-01-27 14:24 project.x01
In addition, the command HRC.Compute_CurrentPlan lngMessages, strMessages() produces following strMessages:
Starting Unsteady Computations
Computing
Computations Completed
- however when I launch the HEC-RAS via schtasks command, Excel/HEC-RAS get launched, even the command HRC.Compute_CurrentPlan lngMessages, strMessages() produces the same correct strMessages:
Starting Unsteady Computations
Computing
Computations Completed
but the model outputs are incomplete, the project.dss is missing:
----------+ 1 matog None 3348 2016-01-27 14:46 project.b01
----------+ 1 matog None 98748 2016-01-27 14:46 project.g01.hdf
----------+ 1 matog None 98748 2016-01-27 14:46 project.g01.tmp.hdf
----------+ 1 matog None 9976 2016-01-27 14:46 project.p01.hdf
----------+ 1 matog None 43292 2016-01-27 14:46 project.x01
Do you have any idea where the HEC-RAS may crash after producing correct messages on HRC.Compute_CurrentPlan output but before writing output data ?
Thanks in advance
Martin
Did you make sure to set all cross sections to produce stage and flow output? From the unsteady flow analysis window, Options...stage and flow output locations.
DeleteHi Chris/Martin
DeleteI am sorry to hijack your conversation, but I am also have the same sort of problems Martin is having... But unlike Martin I am sticking purely within the VBA zone using the HECRASController to try to output stages/flows for a user specified Ri/Re/Node.
My code runs but it only outputs the same first plan/dss file output for each plan i want to output. I have tried to set different dss files for each plan, and even creating different projects for each plan. But the function "RC.OutputDSS_GetStageFlow" will keep outputing the same output...
Is there a way to manually set the different DSS pathnames so that I may run the "RC.OutputDSS_GetStageFlow" inside a for loop to output multiple plans? or maybe you can tell me if I am missing something in my code which I will paste in a reply to this comment.
Sub EXAMPLECODE()
Delete'Open an HEC-RAS Project
Dim RC As New RAS500.HECRASController
OpenRASProjectByRef RC '***Update: removed the "z" before OpenRASProjectByRef
'Run the Project so there's output to retrieve
Dim blnDidItWork As Boolean
Dim blnDidItCompute As Boolean
Dim lngMsg As Long, strMsg() As String
'Compute
'blnDidItWork = RC.Compute_CurrentPlan(lngMsg, strMsg())
'Get a list of the plans
Dim blnIncludeBasePlansOnly As Boolean
Dim lngPlanCount As Long, strPlanNames As String
blnIncludeBasePlansOnly = True
'RC.Plan_Names lngPlanCount, strPlanNames(), _
blnIncludeBasePlansOnly
'Declare looping ints
Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long, p As Long
Dim length As Integer, timesteps As Integer
p = 0
'Select plan
Sheets("RASProjects").Select
Cells.Select
Range("B6").Select
lngPlanCount = ActiveCell.Value
'start loop for plans
For m = 1 To lngPlanCount
Sheets("RASProjects").Select
Cells.Select
Range("B7").Select
ActiveCell.Offset(m, 0).Activate
strPlanNames = ActiveCell.Value
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = "COMPLETE"
'Set the current output plan to next iteration
Dim blnSetIt As Boolean, blnOutputFile As Boolean
Dim strPlanErrMsg As String
'blnOutputFile = RC.PlanOutput_IsCurrent(strPlanNames, True, strPlanErrMsg)
blnSetIt = RC.PlanOutput_SetCurrent(strPlanNames)
Sheets("RASProjects").Select
Cells.Select
Range("M2").Select
length = ActiveCell.Value
ActiveCell.Offset(0, 2).Activate
timesteps = ActiveCell.Value
'Populate a RAS Geometry Type using the GetRiverReachesNodes Function
Dim typRASGeometry As TypeRASGeom
blnDidItWork = GetRiversReachesNodes(typRASGeometry, RC)
'Write results to the excel sheet
Sheets.Add
ActiveSheet.Name = strPlanNames
Sheets(strPlanNames).Select
Cells.Select
Selection.ClearContents
Range("A1").Select
'Rivers
For n = 1 To length
'get first row of selected river/reach/node ids
Sheets("RASProjects").Select
Cells.Select
Range("N3").Select
ActiveCell.Offset(n, 0).Activate
i = ActiveCell.Value
ActiveCell.Offset(0, 2).Activate
j = ActiveCell.Value
ActiveCell.Offset(0, 2).Activate
k = ActiveCell.Value
Application.StatusBar = "Working " & "on River " & i & ", Reach " & j & ", RS " & _
Trim(typRASGeometry.Riv(i).Rch(j).Node(k).RiverStation) & "for plan" & m & " ."
'Go back to output current sheet
Sheets(strPlanNames).Select
Cells.Select
Range("A2").Select
'Reaches
With typRASGeometry.Riv(i)
'write each river/reach
ActiveCell.Offset(0, (n - 1) * 3).Activate: ActiveCell.Value = _
.RivName
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
.Rch(j).RchName
BREAK (cont'd next reply)
(2/2 Cont'd from above comment)
Delete'Nodes
With .Rch(j)
'write each node/RS
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
.Node(k).RiverStation
'Write column headers
ActiveCell.Offset(2, -2).Activate: ActiveCell.Value = _
"Time"
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
"Stage (ft)"
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
"Flow (cfs)"
ActiveCell.Offset(0, -2).Activate
'Declare names of each river, reach and node for each iteration
Dim strRiver As String, strReach As String, strRS As String
strRiver = RC.Geometry.RiverName(i)
strReach = RC.Geometry.ReachName(i, j)
strRS = RC.Geometry.NodeRS(i, j, k)
'Retrieve the output from the dss file
Dim lngNumValue As Long, dblDateTime() As Double, _
sngStage() As Single, sngFlow() As Single, _
strErrMsg As String
blnDidItCompute = RC.OutputDSS_GetStageFlow(strRiver, _
strReach, strRS, lngNumValue, dblDateTime(), _
sngStage(), sngFlow(), strErrMsg)
'Write time/stage/flow
For l = 1 To lngNumValue
ActiveCell.Offset(1, 0).Activate: ActiveCell.Value = _
dblDateTime(l) 'make sure to set this column number format to "time"
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
Round(CStr(sngStage(l + p)), 2)
ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
Round(CStr(sngFlow(l)), 0)
ActiveCell.Offset(0, -2).Activate
Next l
End With
End With
Next n
Next m
'Close HEC-RAS
RC.QuitRAS
End Sub
Logan-
DeleteNOt sure if this is what is causing the problem or not, but the strPlanNames() is an array of plan names and requires an index number when using it to set the current plan. So, when you set it in the command RC.PlanOutput_SetCurrent(), the argument should be an indexed form of strPlanNames(), like strPlanNames(1). Also, I noticed that some important pieces of your code are commented out with an '. I'm guessing that you did that while trying to debug, but thought I'd mention it just in case. Hope this helps.
Chris
Chris,
ReplyDeletethank you very much for your quick response. The problem has been solved - due to the security reasons / OS hardening the model did not write .dss file (and some other files) when running from scheduled task. So my problem is solved.
However it might be worth to change the return value of the call "HRC.Compute_CurrentPlan lngMessages, strMessages()" because in both cases (success, failure) the output was:
Starting Unsteady Computations
Computing
Computations Completed
which was true, however there was no indication that the writing of the output data failed.
Reporting of the output writing failure would help me (and maybe someone else in future) in integration/automation.
Best regards
Martin
Thanks for the fast reply Chris, I will try this now! Will respond in a couple hours.
ReplyDeleteAnd oops sorry about the commented lines, I lose track sometimes of what version I am working on :P.
Cheers,
Chris,
ReplyDeleteYou were right, I assumed from the start I could just pass the function a string, but it turns out it has to have that index number. So instead of grabbing strings from the excel spreadsheet, I am now using the plan_names function to extract all plans in the project.
Thanks,
logan
Great! Hope it works.
DeleteHello Chris
ReplyDeleteI recently purchased your book and i found it really helpful in automating HEC ras for my modeling problem.
So far, i have no issues because the book is very well explained. Just a very small query, there is no QUITRAS command available in the Controller. I am using HEC RAS 4.1 and have looked through the library but this command does not exsit nor does it works.
Well, i have figured another way round to address the problem but i believe that this command can be very helpful.
Looking forward to your reply. Take care.
Regards
Nayyar Minhaj ASIF
Hi Nayyar. Thanks for buying the book. Glad you find it useful. The QuitRAS procedure is new for version 5.0. Since you are using Version 4.1, it won't be there. Sounds like you found a work around, so that's good.
DeleteHello Chris
ReplyDeleteI would appreciate your help over the following issue.
I am trying to extract flow hydrograph for a river station. I am using the OUTOUTDSS_GETSTAGE FLOW command for that. It works fine, however, whatif i want a flow hydrograph through a gated lateral structure? Even if i mention "Lateral Structure RS" in the "FLOW OUTPUT LOCATIONS", it does not give me the gated flow. It gives me the flow at that river station in the river but i would like to have the flow through the gated structure (lateral). How can i handle this?
Currently, i have connected a temporary storage area with my lateral structure to actually extract the hydrograph using the DSS_GETSTAGEFLOWSA but that doesn't seems neat. Any suggestions?
Thanking in advance.
Regards
Nayyar
Forgot to mention.
ReplyDeleteI cannot simply extract discharge of a lateral structure for a fix profile number. The reason is quite weird actually.
I am using rule based BC's for the operations. And there seems a glitch in the HEC RAS output table. The discharge passing through the gates (lateral structure) in the SUMMARY OUTPUT TABLE BY PROFILE is not the same as shown in FLOW HYDROGRAPHS. The values shown in FLOW HYDROGRAPH are correct as those are the values that are writed in the text file and also present in the DSS, however, values shown in SUMMARY OUTPUT TABLE are incorrect. Using the "Discharge extraction by profile number" will give me the wrong value.
As an example,
Hello Chris. I have a question regarding the OUTPUTDSS_GETSTAGEFLOW.
ReplyDeleteDoes this command works for extracting hydrographs of the Lateral Structures i.e. flow flowing through gates??
I know i can extract gate flows through the profiles but that would be requiring post processing which i am looking to avoid. Is there a way to interact with the DSS for extracting hydrographs for lateral structures?
Regards
Nayyar
Hi Chris,
ReplyDeleteWould like to have few clarification to atomize HecRAS setup..
1. I do have sdf file (300mb)generated from ArcGIS for geometry input. How can I import sdf file without using HecRAS GUI. Since it is taking too much time to load in HecRAS.
2. How can I setup a new HecRAS project without using GUI and import all the relevant file in it?
1. You would have to learn the structure of the sdf file, then write code to write a .geo file based on the data in the sdf file. "Breaking the HEC-RAS Code" can help you with the structure of the geometry input file, but this would not be a trivial task.
Delete2. See my answer to question 1.
Hi, Chris,
ReplyDeleteI tested your code above with a replaced path for the Beaver Creek example in HEC-RAS 5.0.3. I used the RAS500 DLL. I got an error message in Microsoft Visual Basic "Run-time error'429':ActiveX component can't create object". What did I miss? Thanks for your time.
Ken Ying
You should use the RAS503 DLL if you are using HEC-RAS 5.0.3.
DeleteChris,
DeleteI got the 4.1 version working. But 5.03 just didn't work. It seems that the function name HECRASController is different in 5.03. Any idea? Thanks.
Chris,
DeleteI tried the RAS503.HECRASController and it gave me the error message: "Compile error: User-defined type not defined".
What line of code returned that error message?
DeleteI received the same message in relation to the line;
DeleteDim RC As New RAS41.HECRASController
Alex, have you added RAS41 as a reference to your code (steps 3 and 4 above)? In any case, I suggest using RAS503 instead. Just make sure you have RAS Version 5.0.3 installed on your computer first.
DeleteHi Chris, we are trying to automate the process in producing flood map and I just want to ask if this is achievable?
ReplyDeleteThanks.
Yes, it's possible, but you'll have to learn how to read from an hdf5 file.
DeleteIs there API calls in the controller to create DSS file and add timeseries data to it?
ReplyDeleteNot to write to the DSS file. You can read from it though. You might explore DSSVue and the DSSVue plugins from the HEC website.
DeleteHi Chris,
ReplyDeleteI just ordered your book and hoping that it is gonna help me with setting up HEC RAS 2D for large areas, with several runs. I hope that I can do following list using the API:
1- Create a new terrain
2- Define 2D flow area
3- Define BCs
4- Mesh generation
5- Assign flow data to BCs
Thank you Hojjat! I’m pretty sure the current version of HRC can’t create a terrain for you or directly define a 2D area, but there’s lots you can do with reading and writing to the input text files that may help you accomplish this. Reading from the HDF files will be useful too.
DeleteHi Chris,
ReplyDeleteI just got your book. What an extensive work!
I'm trying to run a Monte-Carlo simulation using the resources provided in the book. I like you explained the procedure in details but the code that manipulates Manning's n values by reading/rewriting a geometry file is missing. Only the code that is using the HECRASController function Geometry_SetMann_LChR is available. Where can I find the missing code? I appreciate your help on this issue. Thanks!!
-Nathalie
Thanks Nathalie- Glad you enjoy the book. You know, you are the first person to point that out that mistake in the book. The paragraph before the code says the code was written demonstrating reading and writing from/to HEC-RAS text files. Indeed it was originally, but for publishing I switched to the easier Geometry_SetMannLChR function. But, if you would like to see how the geometry text file could be rewritten each realization (instead of using SetMannLChR), page 100 at the bottom begins some code that demonstrates how to do this. Let me know if you have any trouble figuring this out.
DeleteThank you, Chris. I was able to get the geometry file modification to work based on other parts of the book like p.100 you mentioned! Somehow SetMannLChR function doesn't update the n values on me but I'm glad the other approach works. Thank you for being responsive. I saw your recent webinar and that was helpful as well. Keep up the good work!
ReplyDeleteHi Chris,
ReplyDeleteWhen running: RC.OutputDSS_GetStageFlow("RivernName","ReachName","Station",0,0,0,0,"Error")
I got 0 as result.
Would you please advice?
Thanks,
Zara
Dear Chris
ReplyDeleteIs there a way to automatically calculate flood area after a run, that's mean to pilot RasMapper throught an API or with command line ?
Fabrice
Chris:
ReplyDeleteJust a quick head's up, the link at the bottom of this article takes you to https://www.createspace.com/4701459, which I imagine is your admin page for Amazon publishing, rather than to the amazon link itself.
Thanks for the heads up Evan. I've corrected the link now.
Delete-Chris
Hello Chris
ReplyDeleteI’ve just purchased your book and I have a couple questions
1/ Sometimes when running the GetWSELandVelocity code from Chapter 3, when I get WSE and Vel results in my excel sheets, all RS cells are filled with +3.4003x10^38 (max range from single data type). Sometimes I get all my results, the macro works perfectly and it’s the same code, only with the *.prj link address being modified. So it’s obviously depending on the HECRAS project. Would you know why ?
2/I can’t put HEC- DSS Vue or Excel addons on my PC because of company policies. Which command could be used to import hydrograph timeseries from excel to hec ras (so far I only manage to open the unsteady flow data window)?
Thanks very much
Thanks Sebastien! 1. Yes, it definitely depends on the HEC-RAS project. If the active plan of the HEC-RAS project hasn't been run yet, or the output file is missing, the code will not have wsel and velocity data to retrieve and will therefore populate your cells with an "undefined single" number: the +3.4003x10^38. I would rerun your active plan and make sure you can view the output in HEC-RAS. Then make sure you are pointing to the correct HEC-RAS project and the active plan is set to the plan you just ran. If you step through the code in VBA, line by line, you can also see how variables are being populated during run-time. This is a good way to track down errors in code.
Delete2. There is no command in the HECRASController to import a hydrograph. However, you can easily do this programmatically by writing code to rewrite the flow file. The example subroutine "OfftakeFlow" in the book on page 121 can give you some clues on how to do this. Also Chapter 4 is all about reading and writing to the HEC-RAS input files.