Welcome to the RAS Solution Forums HECRAS Controller Geometry Class: subroutine NodeCutLine_Points

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8162
    Solomon
    Participant

    Hi Chris,

    Thank you for this forum!
    I am using Python for working with river geometry using the RASController. I am using your book for this, but I am unable to understand how this call is made. I tried a few combinations – trial and error but didn’t work it out yet. Is there any documentation or example usage/code for this subroutine anywhere?

    Thanks,
    Solomon.

    #13480
    Solomon
    Participant

    After a couple of more tries, I am almost on the verge of giving up using the RASController for extracting the X,Y co-ordinate points from geometry files.

    I know the alternate way of doing it is through direct text mining of the .g* files, but I could really benefit from any previous experience anyone has had in this with the RAS controller. Its worthwhile using the controller because the different versions of HEC-RAS perhaps have different formats of text file (I guess) and I am hoping the controller accounts for that.

    Thanks,
    Solomon.

    #13481
    Chris G.
    Keymaster

    Hi Solomon. Sorry for the delay in getting back to you. Try the Schematic_ReachPoints subroutine for xy coorindates of rivers/reaches. Schematic_XSPoints will get you xy coordinates for the cross sections.

    Here’s a simple subroutine that I wrote for RAS Version 5.0 beta to demonstrate the use of Schematic_ReachPoints. Just copy and paste it into VBA. the mSamples.OpenRASProjectsByRef subroutine that I call has mSamples in front of it because I have it in a different module, called mSamples. You could put the OpenRASProjectsByRef subroutine in the same module, in which case just drop the mSamples part.

    Sub Schematic_ReachPoints()

    ‘**********************************************************
    ‘Demonstrates the Schematic_ReachPoints Subroutine.

    ‘Written by Christopher Goodell
    ‘July 31, 2014

    ‘Returns arrays of rivers, reaches, and _
    arrays of x and y coordinates for each reach. All _
    array parameters are zero-based for this subroutine.

    ‘Tested with the JUNCTION.prj data set. Any HEC-RAS _
    project will work.
    ‘**********************************************************

    ‘Open an HEC-RAS Project
    Dim RC As New RAS500.HECRASController
    mSamples.OpenRASProjectByRef RC

    ‘Get the number of reaches
    Dim lngReachCount As Long
    lngReachCount = RC.Schematic_ReachCount

    ‘Get number of all of the reach points.
    Dim lngAllReachPointCount As Long
    lngAllReachPointCount = RC.Schematic_ReachPointCount

    ‘Dimension the arrays
    Dim strRiverName() As String, strReachName() As String, _
    lngReachStartIndex() As Long, _
    lngReachPointCount() As Long, _
    dblReachPointX() As Double, dblReachPointY() As Double

    ‘Redim to zero-based arrays
    ReDim strRiverName(lngReachCount – 1)
    ReDim strReachName(lngReachCount – 1)
    ReDim lngReachStartIndex(lngReachCount – 1)
    ReDim lngReachPointCount(lngReachCount – 1)
    ReDim dblReachPointX(lngAllReachPointCount – 1)
    ReDim dblReachPointY(lngAllReachPointCount – 1)

    ‘Get the arrays
    RC.Schematic_ReachPoints strRiverName(), strReachName(), _
    lngReachStartIndex(), lngReachPointCount(), _
    dblReachPointX(), dblReachPointY()

    ‘Clear the Output spreadsheet
    Sheets(“Output”).Select
    Cells.Select
    Selection.ClearContents

    ‘Write column headers
    Range(“A1”).Select
    ActiveCell.Value = “Reach Points”
    ActiveCell.Offset(1, 0).Activate: ActiveCell.Value = _
    “River”
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    “Reach”
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    “X Coord”
    ActiveCell.Offset(0, 1).Activate: ActiveCell.Value = _
    “Y Coord”
    ActiveCell.Offset(0, -3).Activate

    ‘Write Data to Output Spreadsheet
    Dim i As Integer, j As Integer
    For i = 0 To lngReachCount – 1
    ActiveCell.Offset(1, 0).Activate
    ActiveCell.Value = strRiverName(i)
    ActiveCell.Offset(0, 1).Activate
    ActiveCell.Value = strReachName(i)
    ActiveCell.Offset(0, 1).Activate
    For j = lngReachStartIndex(i) To _
    lngReachStartIndex(i) + lngReachPointCount(i) – 1
    ActiveCell.Value = dblReachPointX(j)
    ActiveCell.Offset(0, 1).Activate
    ActiveCell.Value = dblReachPointY(j)
    ActiveCell.Offset(1, -1).Activate
    Next j
    ActiveCell.Offset(0, -2).Activate
    Next i

    ‘Close HEC-RAS
    RC.QuitRAS

    End Sub

    Sub OpenRASProjectByRef(ByRef RC As RAS500.HECRASController)

    ‘**********************************************************
    ‘Demonstrates Project_Open subroutine and how to pass the _
    HECRASController as a reference.

    ‘Written by Christopher Goodell
    ‘July 3, 2012

    ‘Opens a RAS project by being called from another _
    subroutine
    ‘**********************************************************

    ‘Open the HEC-RAS Project
    Dim strFilename As String
    Sheets(“RASProjects”).Select
    strFilename = Range(“C4”).Value
    RC.Project_Open strFilename

    End Sub

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.