Está en la página 1de 1

Yes...

there is a "Run Multiple Plans" menu item already in HEC-RAS, but for fun, I've written a simple
subroutine that does the same thing. This subroutine might serve as a starting point for a more
sophisticated Monte Carlo simulation or an optimization run. Give it a try...

Sub RunMultiplePlans()

'**********************************************************
'Demonstrates Project_Open subroutine and the _
Compute_CurrentPlan function in a Do-Loop to run _
mulitple plans.

'Written by Christopher Goodell


'March 5, 2015
'**********************************************************

'Instantiate a new HECRASController


Dim RC As New RAS500.HECRASController

'Open a new project


Dim strFilename As String
Sheets("RASProjects").Select
strFilename = Range("C4").Value 'In Cell C4, Paste in _
path and filename of the RAS project you want to open.
RC.Project_Open (strFilename)

'Determine the number of plans


Dim blnIncludeBasePlansOnly As Boolean
Dim lngPlanCount As Long, strPlanNames() As String
blnIncludeBasePlansOnly = True
RC.Plan_Names lngPlanCount, strPlanNames(), _
blnIncludeBasePlansOnly

'Loop through the plans and run each one.


Dim i As Integer
Dim blnSetIt As Boolean
Dim lngMessages As Long
Dim strMessages() As String
Dim blnDidItCompute As Boolean
i=1
Do Until i > lngPlanCount
blnSetIt = RC.Plan_SetCurrent(strPlanNames(i))
i=i+1

'Compute the selected plan.


blnDidItCompute = RC.Compute_CurrentPlan(lngMessages, _
strMessages(), True)
Loop

MsgBox "Done!"

'Close HEC-RAS
RC.QuitRAS
End Sub

Chris G.
@RASModel

También podría gustarte