Welcome to the RAS Solution › Forums › HECRAS Controller › Compute_CurrentPlan RASController in Program R
- This topic has 3 replies, 955 voices, and was last updated 8 years ago by Toby.
-
AuthorPosts
-
April 30, 2018 at 6:25 am #8214TobyParticipant
First off thanks Chris G. for your webinar on RASController recently good stuff. I got the book and am now trying to convert some of this to program R.
I have imported the COM object, and can open RAS and do a few basic things (very similar post as Chris Kelley’s post in C# Link here)
I cannot figure out how to get the Compute_CurrentPlan to work. Has anyone accomplished this in R?
Here is what I have so far…
# Ensure required packages are loaded
library(RDCOMClient)# To see all COM objects
# Launch the Registry Editor.
# Click Start, and then click Run.
# In the Open box, type “regedit”, and then click OK.
# on the left expand HKEY_CLASSES_ROOT
# Look for RAS objects# Open the RAS Controller
# Dim HRC As New HECRASController
HRC <- COMCreate("RAS503.HECRASController") #RF <- COMCreate("RAS503.HECRASFlow") #RG <- COMCreate("RAS503.HECRASGeometry") ############################################################################# # Open a new project. # Dim strRASProject As String strRASProject = "C:\\Users\\m.modeler\\Documents\\HEC_RAS_EXAMPLES\\Example Projects\\1D Unsteady Flow Hydraulics\\Balde Eagle Creek\\BaldEagle.prj" # HRC.Project_Open strRASProject HRC$Project_Open(strRASProject) HRC$CurrentGeomFile() HRC$CurrentPlanFile() HRC$CurrentSteadyFile() HRC$CurrentUnsteadyFile() HRC$CurrentProjectTitle() HRC$Schematic_ReachCount() # Open plan editor HRC$Edit_PlanData() # Run the HEC-RAS Project # Dim lngMessages As Long # Dim strMessages() As String # HRC.Compute_CurrentPlan lngMessages, strMessages() # ***This is where the issues occur*** lngMessages<-as.integer() strMessages<-as.character() HRC$Compute_ShowComputationWindow() HRC$Compute_CurrentPlan(lngMessages, strMessages) # ***This is where the issues occur*** # Get water surface elevations at Node 5 # Dim sngWSElev As Single # sngWSElev = HRC.Output_NodeOutput(1, 1, 5, 0, 1, 2) # riv = river ID # rch = reach ID # n = node ID # updn = 0 for US, 1 for BR UP, 2 for BR DS, # prof = profile ID # nVar - variable ID WSElev <- HRC$Output_NodeOutput(1, 1, 5, 0, 1, 2) Q_Total <- HRC$Output_NodeOutput(1, 1, 5, 0, 1, 9) #Plot HRC$plotXS(1,1,5) # MsgBox "The water surface elevation is " & sngWSElev & "." print(paste0("The max water surface elevation is ", round(WSElev,2), ".")) print(paste0("The max Q total is ", round(Q_Total,2), ".")) #HRC.QuitRas HRC$Project_Save() HRC$Project_Close() HRC$QuitRas ############################################ # Garbage Can gc() Any help would be great! Thanks much, TobySeptember 24, 2018 at 1:30 pm #13584CharlieFParticipantHi. Thanks for this- really clear.
Did you ever manage to get Compute_CurrentPlan() to work?September 24, 2018 at 6:57 pm #13585AnonymousGuestHi,
I never got it to work, but I also have not revisited this. Not enough time. If you had any ideas I would love to hear them.
thanks,
TobySeptember 26, 2018 at 6:46 pm #13586AnonymousGuestHi Charlie,
You can try playing around with the link posted above where a similar issue was found in another programming language. I am not sure how to fix it. Good luck.
-
AuthorPosts
- You must be logged in to reply to this topic.