Welcome to the RAS Solution Forums HECRAS Controller OUtput_Nodeoutput only read out the first plan file in the loop

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8187
    hillwinner
    Participant

    Hi Chris,

    I have the code to batch run RAS and read out the stage for a multi-plan project. I set a loop (Line 63), RAS runs for different plans (plan 5 and plan 6) but the Output_Nodeoutput always read out the first plan (plan 5 only and didn’t read plan 6). Anyone can see anything I did wrong in the code?

    Thanks

    Shan

    The code as Follows:
    ————————————————————–

    Sub BatchRunAndPostprocess()

    ‘————————————–

    Dim strProjectFileName As String
    strProjectFileName = “C:\” & _
    “RAS_BatchRuns0915\runs” & _
    “\XS-1916\XS-1916.prj”

    ‘Open the HEC-RAS project
    Dim RC As New HECRASController
    RC.Project_Open strProjectFileName

    ‘Determine the number of plans
    Dim lngPlanCount As Long
    Dim strPlanNames() As String
    Dim blnIncludeOnlyPlansInDirectory As Boolean
    RC.Plan_Names lngPlanCount, strPlanNames(), blnIncludeOnlyPlansInDirectory

    ‘Determine the number of RS’s in River 1 and Reach 1
    Dim lngNumRS As Long
    lngNumRS = RC.Geometry.nNode(1, 1)

    ‘Get River Stations
    Dim strRS() As String
    Dim strNodeType() As String
    RC.Geometry_GetNodes 1, 1, lngNumRS, strRS(), strNodeType()

    ‘Output the River Station ID and Plan Names
    ‘ to RiverStationID sheet.
    Dim i As Long, j As Long
    Dim blnSheetExists As Boolean
    For i = 1 To Sheets.Count
    If Sheets(i).Name = “RiverStationID” Then
    blnSheetExists = True
    End If
    Next i
    If blnSheetExists = False Then
    Sheets.Add
    ActiveSheet.Name = “RiverStationID”
    End If
    Sheets(“RiverStationID”).Select

    For i = 1 To lngNumRS
    Cells(i, 1).Value = i
    Cells(i, 2).Value = strRS(i)
    Cells(i, 3).Value = strNodeType(i)
    Next i

    ‘Cells(1, 4).Value = lngPlanCount
    For i = 1 To lngPlanCount
    Cells(i, 4).Value = i
    Cells(i, 5).Value = strPlanNames(i)
    Next i
    ‘—————————————-
    ‘Run HEC-RAS and Postprocess by loop through

    Dim blnSetIt As Boolean
    Dim lngMessages As Long
    Dim strMessages() As String
    Dim blnDidItCompute As Boolean

    For iplan = 5 To 6 ‘lngPlanCount

    blnSetIt = RC.Plan_SetCurrent(strPlanNames(iplan))
    RC.Project_Save
    RC.Project_Open strProjectFileName

    blnDidItCompute = RC.Compute_CurrentPlan(lngMessages, strMessages())

    ‘—————————————-
    ‘Determine the number of profiles
    Dim lngNumProf As Long
    Dim strProfileName() As String
    RC.Output_GetProfiles lngNumProf, strProfileName()

    MsgBox “Current PlanName=” & strPlanNames(iplan) & ” nProfile=” & lngNumProf

    ‘Get initial stages. Uses profile number 2, since profile
    ‘ number 1 is the MaxWS profile. number 2 is 1st initial
    Dim sngMaxStage() As Single: ReDim sngMaxStage(1 To _
    lngNumRS)
    Dim lngNVar As Long
    lngNVar = 2 ‘Output ID # for W/S Elevation
    For i = 1 To lngNumRS
    Application.StatusBar = “Getting maximum stage ” & _
    “for node ID ” & i & “.”
    sngMaxStage(i) = RC.Output_NodeOutput(1, 1, i, 0, 1, _
    lngNVar)
    Next i

    ‘First check to see if the worksheet “strPlanName”
    ‘ already exists. If not, add a new sheet and name it.
    blnSheetExists = False
    For i = 1 To Sheets.Count
    If Sheets(i).Name = strPlanNames(iplan) Then
    blnSheetExists = True
    End If
    Next i

    ‘If “RASResults” does not exist as a sheet, we’ll
    ‘ add it.
    If blnSheetExists = False Then
    Sheets.Add
    ActiveSheet.Name = strPlanNames(iplan)
    End If
    Sheets(strPlanNames(iplan)).Select

    ‘Clear all the data so that can construct a fresh table _
    of data.
    Cells.Select
    Cells.Delete

    ‘Give the first column header.
    Range(“A1”).Select
    ActiveCell.Value = “DateAndTime”
    For j = 2 To lngNumProf
    Cells(j, 1).Value = strProfileName(j)
    Next j

    ‘Go through each cross section and profile
    ‘ to assign value to 2-d array for selected RS
    Dim lngNumSelectedRS As Long
    lngNumSelectedRS = 7

    Dim lngSelectedRS() As Long: ReDim lngSelectedRS(1 To lngNumSelectedRS) As Long
    Dim sngTmpStage As Single
    Dim sngStage() As Single: ReDim sngStage(1 To _
    lngNumSelectedRS, 1 To lngNumProf)
    lngSelectedRS(1) = 228
    lngSelectedRS(2) = 221
    lngSelectedRS(3) = 189
    lngSelectedRS(4) = 152
    lngSelectedRS(5) = 130
    lngSelectedRS(6) = 109
    lngSelectedRS(7) = 7
    For i = 1 To lngNumSelectedRS
    Cells(1, i + 1) = strRS(lngSelectedRS(i))
    For j = 2 To lngNumProf
    Application.StatusBar = “Reading ” & _
    “Plan ” & strPlanNames(iplan) & _
    ” River Station ” & i _
    & “of ” & lngNumSelectedRS & “, ” & _
    “Profile ” & j & “.”
    sngStage(i, j) = RC.Output_NodeOutput(1, 1, _
    lngSelectedRS(i), 0, j, 2)
    Cells(j, i + 1).Value = sngStage(i, j)
    Next j
    Next i

    ‘Finish
    Next iplan
    ‘MsgBox “Done!”
    Application.StatusBar = “Finished!”
    ‘RC.QuitRAS

    End Sub

    #13516
    Anonymous
    Guest

    I came across this question while searching for a solution to my own problem. I was having trouble looping through already computed plans changing them with .PlanOutput_SetCurrent and .Plan_SetCurrent then extracting results using .Output_NodesOutput . It just seemed like the output file was not being updated. The solution was to change the plan, save it, close the project and then re-open it:

    RC.Plan_SetCurrent (strPlanNames(j))
    RC.Project_Save
    RC.Project_Close
    RC.Project_Open strRASProject

    Hopefully this will save someone the time it took me to figure this out…

    #13517
    Chris G.
    Keymaster

    Return-Path: Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
    by sloti1d2t14 (Cyrus 3.1.3-653-gce35ffd-fastmail) with LMTPA;
    Tue, 19 Jun 2018 15:43:53 -0400
    X-Cyrus-Session-Id: sloti1d2t14-4182396-1529437433-2-15320352326950809254
    X-Sieve: CMU Sieve 3.0
    X-Spam-known-sender: no
    X-Spam-score: 0.0
    X-Spam-hits: BAYES_00 -1.9, FREEMAIL_FROM 0.001, HTML_MESSAGE 0.001, ME_BETA_RULES 0.01,
    RCVD_IN_DNSWL_NONE -0.0001, RCVD_IN_MSPIKE_H3 -0.01,
    RCVD_IN_MSPIKE_WL -0.01, SPF_PASS -0.001, URI_HEX 1.122, LANGUAGES en,
    BAYES_USED global, SA_VERSION 3.4.0
    X-Spam-source: IP=’209.85.214.52′, Host=’mail-it0-f52.google.com’, Country=’US’,
    FromHeader=’com’, MailFrom=’com’
    X-Spam-charsets: plain=’us-ascii’, html=’utf-8′
    X-Resolved-to: [email protected]
    X-Delivered-to: [email protected]
    X-Mail-from: [email protected]
    Received: from mx4 ([10.202.2.203])
    by compute1.internal (LMTPProxy); Tue, 19 Jun 2018 15:43:53 -0400
    Received: from mx4.messagingengine.com (localhost [127.0.0.1])
    by mailmx.nyi.internal (Postfix) with ESMTP id BC118C86CB
    for ; Tue, 19 Jun 2018 15:43:52 -0400 (EDT)
    Received: from mx4.messagingengine.com (localhost [127.0.0.1])
    by mx4.messagingengine.com (Authentication Milter) with ESMTP
    id 30DAC181C53;
    Tue, 19 Jun 2018 15:43:52 -0400
    ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=fm3; t=
    1529437432; b=Hs5q8xAiLNfAHCuMjmFUiHe2o2DPgHAQ3DxjImw1LSLUTpGkNW
    2t86IEYMwZr5V/60yhitfTI1VhDEKKNsMonjkXOPLP5wHXnFDZpBaDHA+FNPNlzV
    yNcs4S9EQ+8mXoegNZSg7cEGmusujol27yLCFlE+4KwJuKO5IduHOYo7meQbB/eh
    OMfOZ9vOZeUf5/S7JQTARB8b7TefY/fUv7DlNXc+AHOr39zKwUgb5uvqKyWsg61P
    GUuxojrU75K9JkhK2TzPnWZdH1ZweRU2/BeBgO7C0fAzsjm1s4S7sTi4HTEsMEH4
    aujhkK2oeUaIFqCWt+MRx5uvbVvpthUTA8WQ==
    ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=
    messagingengine.com; h=from:content-type
    :content-transfer-encoding:mime-version:date:subject:message-id
    :references:in-reply-to:to; s=fm3; t=1529437432; bh=2r47bexiWx1n
    zRXLloXjxgjGHPrJtPXdi6KXfQBpRyA=; b=K6b4nJCijfuX1MKwPFqvZKn699k4
    q53KG3cHQZuW/erxmKOMz2RlkuM22nNqRguGzwbAnDEA4RdPWwWrAT4qXiqP1qoc
    byvgQmvGbHDmYNXLGseIYiwjRpUFliyTIFsEVUIjS/JHHUqGgll/Sy03SSQ6WBhQ
    R81qPfnFiV3Dqz6Pz5U/pI7o6EdCZkaKmj9LYv9/UwKtw3Kqa2UU1C45GKH5ftvs
    UE5Bi09dry76eEHj0OccB20oNut1c5+KazWdumANxidebu6r2Zkv3GE2OjefQ1QU
    ijiTBFJzRrvKNzr9WpLcLDW3yNEoz9ZP85tsgnKyszUxB2nHCyCTMIpEzw==
    ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found);
    dkim=pass (2048-bit rsa key sha256) header.d=gmail.com
    [email protected] header.b=nYKacmEE header.a=rsa-sha256
    header.s=20161025 x-bits=2048;
    dmarc=pass (p=none,sp=quarantine,d=none) header.from=gmail.com;
    iprev=pass policy.iprev=209.85.214.52 (mail-it0-f52.google.com);
    spf=pass [email protected]
    smtp.helo=mail-it0-f52.google.com;
    x-aligned-from=pass (Address match);
    x-cm=none score=0;
    x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net
    [email protected] header.b=eDEpokn8;
    x-ptr=pass smtp.helo=mail-it0-f52.google.com
    policy.ptr=mail-it0-f52.google.com;
    x-return-mx=pass header.domain=gmail.com policy.is_org=yes
    (MX Record found);
    x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes
    (MX Record found);
    x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES128-GCM-SHA256
    smtp.bits=128/128;
    x-vs=clean score=0 state=0
    Authentication-Results: mx4.messagingengine.com;
    arc=none (no signatures found);
    dkim=pass (2048-bit rsa key sha256) header.d=gmail.com
    [email protected] header.b=nYKacmEE header.a=rsa-sha256
    header.s=20161025 x-bits=2048;
    dmarc=pass (p=none,sp=quarantine,d=none) header.from=gmail.com;
    iprev=pass policy.iprev=209.85.214.52 (mail-it0-f52.google.com);
    spf=pass [email protected]
    smtp.helo=mail-it0-f52.google.com;
    x-aligned-from=pass (Address match);
    x-cm=none score=0;
    x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net
    [email protected] header.b=eDEpokn8;
    x-ptr=pass smtp.helo=mail-it0-f52.google.com
    policy.ptr=mail-it0-f52.google.com;
    x-return-mx=pass header.domain=gmail.com policy.is_org=yes
    (MX Record found);
    x-return-mx=pass smtp.domain=gmail.com policy.is_org=yes
    (MX Record found);
    x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES128-GCM-SHA256
    smtp.bits=128/128;
    x-vs=clean score=0 state=0
    X-ME-VSCategory: clean
    X-CM-Envelope: MS4wfNBndLMZN7DGLOeAlcEzoJQ7Aw5A++1D4IKZLU81DEu7uUv032wHqR54hbeCkAy01Eroeddignf3dLkVRVwQbTrmnCxp16oCi2VPVlvi/kZioq4IWueK
    hh0zMQuwPQ8ycwttYEw0U5kdAYgMX9Z73+9pxVBSzpRMWt6RJdEarXzA9iktnADQxQYBzANbTTwBFPx3rhg73sjfvRqE/kN6v9FlG6giHyL8tvwA5d2ra59D
    X-CM-Analysis: v=2.3 cv=Ls28NEVc c=1 sm=1 tr=0 a=FiysPuC7j0KWWPdSEIJ08g==:117
    a=B3oEefHhFTcVlgahaZg/xQ==:17 a=x7bEGLp0ZPQA:10 a=po3G2Dre0K0A:10
    a=7mUfYlMuFuIA:10 a=9I5xiGouAAAA:8 a=OUyWigE-sChnsJ-678QA:9 a=CjuIK1q_8ugA:10
    a=lg4JEFhukzMA:10 a=Cc_MeekYKk0A:10 a=7ROToYf0qM204g9Z:21 a=_W_S_7VecoQA:10
    a=QEXdDO2ut3YA:10 a=ARFN2YZ7Uv8kHtb7LS-q:22
    X-ME-CMScore: 0
    X-ME-CMCategory: none
    Received-SPF: pass
    (gmail.com … _spf.google.com: Sender is authorized to use ‘[email protected]’ in ‘mfrom’ identity (mechanism ‘include:_netblocks.google.com’ matched))
    receiver=mx4.messagingengine.com;
    identity=mailfrom;
    envelope-from=”[email protected]”;
    helo=mail-it0-f52.google.com;
    client-ip=209.85.214.52
    Received: from mail-it0-f52.google.com (mail-it0-f52.google.com [209.85.214.52])
    (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
    (No client certificate requested)
    by mx4.messagingengine.com (Postfix) with ESMTPS
    for ; Tue, 19 Jun 2018 15:43:52 -0400 (EDT)
    Received: by mail-it0-f52.google.com with SMTP id a3-v6so2161736itd.0
    for ; Tue, 19 Jun 2018 12:43:52 -0700 (PDT)
    DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=gmail.com; s=20161025;
    h=from:content-transfer-encoding:mime-version:date:subject:message-id
    :references:in-reply-to:to;
    bh=2r47bexiWx1nzRXLloXjxgjGHPrJtPXdi6KXfQBpRyA=;
    b=nYKacmEEHbYWZP9N6yrqrN0H8QRnR/FHr1nwWWYaM/+eM2ARlFJ/xp2TuQLMrgeAcK
    MrZlatCTAfriAUm92pFnMA0jcdv6jn9iscqGzVL8qQkcjo7M0oKgZiUCPmJ04qMUptNy
    7gleU9ItogoYOwit19myBUiqjTUVBV46wiN7aOiC/yKrzPhzmhx7W1+ZPNk42zc3tPYE
    EmBEGSum4A6b92gLpXjDhMSmHAFFT+bl0OPNClUif7rftoMB+D/1maNSHlCr4+/US2wk
    kyTbI3pSltu0o4+ToCn0YltOIWwFDMYMoiFQwvfnw5pzBsabBPjgavcLJ7/VdknXH0H7
    j4AQ==
    X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=1e100.net; s=20161025;
    h=x-gm-message-state:from:content-transfer-encoding:mime-version:date
    :subject:message-id:references:in-reply-to:to;
    bh=2r47bexiWx1nzRXLloXjxgjGHPrJtPXdi6KXfQBpRyA=;
    b=eDEpokn84J98AidlxZeQT1tuh4ogc7nzeHxlhgZVXYYLE/bmFOj22hOAPaP4L6VC6C
    f4YExUL2AX6hhc7hvo5VaTfFlJ6/qBkf2PQen6SRVcE4g+BuC/MsWqOSsPDUBqyQsDkc
    1WvPIG+vrMHdqU09u9x4tOlG7VBX3FoyMuYaoJmYL33Uq3bLmTLQIsHufjriJqf0BUA6
    inkR8QErJ2XYS7KmO29gtAPJ3bpuSaVv4ZtDSTVDsWMkyDGYv620+UaSQiAeH/ldPXqy
    WIoAq2DrPGczJ+Drs4a6JHevAwo+jQRY3EkJ2MmfhXvgDMC69xoTmSMuy1L5IQMTlCuJ
    ZVXQ==
    X-Gm-Message-State: APt69E2ILG5bWGO5+Gu1EUsdiZoaAh1t0LaMPPKiDQ3p5FCvqc3siWz9
    RuPe8yNZ++izTx9J1PqCXFfYceUl
    X-Google-Smtp-Source: ADUXVKLCT/mj/DKSp6pKt56g2EMjo48SDaFkKanKk8Ie5RbBgzeZuYOtlwavixV1tqjK/RBGjCpkzA==
    X-Received: by 2002:a24:f04e:: with SMTP id p14-v6mr14203231iti.106.1529437430322;
    Tue, 19 Jun 2018 12:43:50 -0700 (PDT)
    Received: from [100.91.9.168] (mad5036d0.tmodns.net. [208.54.80.173])
    by smtp.gmail.com with ESMTPSA id f3-v6sm189041iob.49.2018.06.19.12.43.49
    for
    (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
    Tue, 19 Jun 2018 12:43:49 -0700 (PDT)
    From: The RAS Solution Content-Type: multipart/alternative;
    boundary=Apple-Mail-0D8518DA-C0FB-4B1A-AF48-C08B25D6A084
    Content-Transfer-Encoding: 7bit
    Mime-Version: 1.0 (1.0)
    Date: Tue, 19 Jun 2018 20:43:47 +0100
    Subject: Re: OUtput_Nodeoutput only read out the first plan file in the loop
    Message-Id: <[email protected]>
    References: <[email protected]> <[email protected]>
    In-Reply-To: <[email protected]>
    To: “Ski907 [via HEC-RAS Help]”
    X-Mailer: iPhone Mail (15F79)

    –Apple-Mail-0D8518DA-C0FB-4B1A-AF48-C08B25D6A084
    Content-Type: text/plain;
    charset=us-ascii
    Content-Transfer-Encoding: quoted-printable

    Thanks for posting!

    Sent from my iPhone

    > On Jun 19, 2018, at 1:41 AM, Ski907 [via HEC-RAS Help] wrote:
    >=20
    > I came across this question while searching for a solution to my own probl=
    em. I was having trouble looping through already computed plans changing the=
    m with .PlanOutput_SetCurrent and .Plan_SetCurrent then extracting results u=
    sing .Output_NodesOutput . It just seemed like the output file was not being=
    updated. The solution was to change the plan, save it, close the project an=
    d then re-open it:=20
    >=20
    > RC.Plan_SetCurrent (strPlanNames(j))=20
    > RC.Project_Save=20
    > RC.Project_Close=20
    > RC.Project_Open strRASProject =20
    >=20
    >=20
    > Hopefully this will save someone the time it took me to figure this out…=
    =20
    >=20
    > If you reply to this email, your message will be added to the discussion b=
    elow:
    > http://hec-ras-help.1091112.n5.nabble.com/OUtput-Nodeoutput-only-read-out-=
    the-first-plan-file-in-the-loop-tp3151p5781.html
    > To start a new topic under HECRAS Controller, email ml+s1091112n1184h88@n5=
    .nabble.com=20
    > To unsubscribe from HECRAS Controller, click here.
    > NAML

    –Apple-Mail-0D8518DA-C0FB-4B1A-AF48-C08B25D6A084
    Content-Type: text/html;
    charset=utf-8
    Content-Transfer-Encoding: 7bit

    Thanks for posting!

    Sent from my iPhone
    On Jun 19, 2018, at 1:41 AM, Ski907 [via HEC-RAS Help] <[email protected]> wrote:

    I came across this question while searching for a solution to my own problem. I was having trouble looping through already computed plans changing them with .PlanOutput_SetCurrent and .Plan_SetCurrent then extracting results using .Output_NodesOutput . It just seemed like the output file was not being updated. The solution was to change the plan, save it, close the project and then re-open it:

    RC.Plan_SetCurrent (strPlanNames(j))

            RC.Project_Save

            RC.Project_Close

            RC.Project_Open strRASProject  

    Hopefully this will save someone the time it took me to figure this out…


    If you reply to this email, your message will be added to the discussion below:

    http://hec-ras-help.1091112.n5.nabble.com/OUtput-Nodeoutput-only-read-out-the-first-plan-file-in-the-loop-tp3151p5781.html

    To start a new topic under HECRAS Controller, email [email protected]
    To unsubscribe from HECRAS Controller, click here.
    NAML


    –Apple-Mail-0D8518DA-C0FB-4B1A-AF48-C08B25D6A084–

    #13518
    Anonymous
    Guest

    Thanks Ski901! I just ran into this issue with version 5.0.4 of the RAS Controller and your method to save and re-open worked.

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