The WEAPBranch class represents a specific Branch on the data tree (e.g., \Demand Sites\South City ), whereas WEAPBranches is a collection of all child Branches for a specified Branch (e.g., all child branches of \Demand Sites ).
You can get access to a WEAPBranches collection in two different ways:
The Branches property of the WEAPApplication class, giving all branches, WEAP.Branches
From the Children property of a WEAPBranch, e.g., WEAP.Branch("\Demand Sites").Children
You can get access to a WEAPBranch in three different ways:
WEAPApplication.Branch(FullBranchPath), e.g., WEAP.Branch("\Demand Sites\South City")
WEAPBranches(Index), specifying a number from 1 to WEAPBranches.Count, e.g., WEAP.Branch("\Demand Sites").Children(1)
Iterate through the collection of all branches, e.g., For Each Branch in WEAP.Branches
WEAPBranches Properties and Methods |
Example (using VB script) |
Choose(Title, Default, MaxChoices, UseFullPath): Ask user to choose items from the branch collection. If the optional parameter Default is given, it has the comma-separated list of items that are initially checked. If the optional parameter MaxChoices is given, it has the maximum number of choices permitted. If not given or zero, there is no maximum. If the optional parameter UseFullPath is given, the branch list shown to the user will use the full branch path (e.g., \Demand Sites\South City) instead of the short name (e.g., South City). The return value is another WEAPBrances collection containing the selected items. If none were selected, the collection will be empty. Note: because it returns a WEAPBranches collection, you can string together several in one statement, e.g., WEAP.DemandSites.FilterByTag("South").FilterByScenario("Not:Current Accounts").Choose("Select Demand Sites to set active in Current Accounts").NameList |
' Ask the user which demand sites to activate FOR EACH Br IN WEAP.DemandSites.FilterByScenario("Not:Current Accounts").Choose("Select Demand Sites to set active in Current Accounts") Br.ActiveInCurrentAccounts = TRUE NEXT ' Ask user to choose one demand site DS = WEAP.DemandSites.Choose("Select one Demand Site to process", "", 1) |
Count: Get the number of WEAP branches in the collection. Read only. |
FOR i = 1 to WEAP.Branch("\Demand
Sites").Children.Count ' Note: The following is equivalent and easier to understand: FOR EACH Br IN WEAP.Branch("\Demand
Sites").Children |
FilterByName(Names): Gets subset of branches in the collection whose name matches one of the names in Names parameter (separated by commas). To allow partial matches, prefix with "Partial:", e.g., "Partial:Corn". To find branches that do NOT match, prefix with "Not:", .e.g., "Not:Forest". Returns a WEAPBranches collection. Read only. Note: because it returns a WEAPBranches collection, you can string together several in one statement, e.g., WEAP.Catchments.FilterByName("Partial:Fresno").FilterByScenario("Not:Current Accounts").Choose("Select Catchments to set active in Current Accounts") |
' Set Soil Water Capacity to 1000 mm for all Forest and Grassland branches FOR EACH Br IN WEAP.Branch("\Demand Sites").Descendants.FilterByName("Forest,Grassland") IF Br.VariableExists("Soil Water Capacity") THEN Br.Variable("Soil Water Capacity").Expression = 1000 END IF NEXT ' Set Soil Water Capacity to 250 mm for all non Forest and Grassland branches FOR EACH Br IN WEAP.Branch("\Demand Sites").Descendants.FilterByName("Not:Forest,Grassland") IF Br.VariableExists("Soil Water Capacity") THEN Br.Variable("Soil Water Capacity").Expression = 250 END IF NEXT |
FilterByScenario(Scenarios): Gets subset of branches in the collection that are active in any of the scenarios in Scenarios parameter (separated by commas). To find branches that are NOT active in any scenario listed, prefix with "Not:", .e.g., "Not:Current Accounts,Reference" would match branches that were not active in Current Accounts or the Reference scenario. Returns a WEAPBranches collection. Read only. Note: because it returns a WEAPBranches collection, you can string together several in one statement, e.g., WEAP.DemandSites.FilterByTag("South").FilterByScenario("Not:Current Accounts").Choose("Select Demand Sites to set active in Current Accounts") |
' Ask user which active demand sites to deactivate FOR EACH Br IN WEAP.DemandSites.FilterByScenario("Current Accounts").Choose("Select Demand Sites to make NOT active in Current Accounts") Br.ActiveInCurrentAccounts = FALSE NEXT ' Ask user which inactive reservoirs to activate FOR EACH Br IN WEAP.Reservoirs.FilterByScenario("Not:Current Accounts").Choose("Select Reservoirs to make active in Current Accounts") Br.ActiveInCurrentAccounts = TRUE NEXT |
FilterByTag(Tags): Gets subset of branches in the collection that have any of the tags in Tags parameter (separated by commas). To find branches that do NOT match, prefix with "Not:", .e.g., "Not:South" would match branches that did not have a "South" tag. Returns a WEAPBranches collection. Read only. Note: because it returns a WEAPBranches collection, you can string together several in one statement, e.g., WEAP.DemandSites.FilterByTag("South").FilterByScenario("Not:Current Accounts").Choose("Select Demand Sites to set active in Current Accounts") |
' Activate all catchments with the tag "American River Bsain" FOR EACH Br in WEAP.Catchments.FilterByTag("American River Basin") Br.ActiveInCurrentAccounts = True NEXT |
FilterByType(Types): Gets subset of branches in the collection whose type matches one of the types in Types parameter (separated by commas). To find branches that do NOT match, prefix with "Not:", .e.g., "Not:Reservoir". Returns a WEAPBranches collection. Read only. Note: because it returns a WEAPBranches collection, you can string together several in one statement, e.g., WEAP.Branch("Gauge 101").UpstreamNodes.FilterByType("Catchments").FilterByScenario("Not:Current Accounts").Choose("Select Catchments to set active in Current Accounts") |
' Calculate the total population of all demands sites downsteam of North Reservoir TotalPopulation = 0 FOR EACH Br IN WEAP.Branch("North Reservoir").DownstreamNodes(True).FilterByType("Demand Site") IF Br.Variable("Annual Activity Level").Unit = "cap" THEN ' is the unit population? Population = Br.Variable("Annual Activity Level").Scale * Br.Variable("Annual Activity Level").ResultValue(WEAP.BaseYear, 1) Print Br.FullName & " " & WEAP.BaseYear & " population = " & Population TotalPopulation = TotalPopulation + Population END IF NEXT Print "Total " & WEAP.BaseYear & " population = " & TotalPopulation |
FullNameList: Get a list of branch names (using the full path) separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only. |
DSToDelete = WEAP.Choose("Choose Demand Sites to delete", WEAP.DemandSites.FullNameList) FOR EACH BranchName in Split(DSToDelete, ",") WEAP.Branch(BranchName).Delete NEXT Print WEAP.Gauges.FullNameList(";") ' Get list of gauges, separated by semicolons |
Item(BranchNameOrIndex): Get the branch identified by the branch name or index (from 1 to Count). Item is the "default" property, and therefore is usually omitted. Thus, the first two examples to the right are equivalent. If the BranchName matches multiple branches in the collection, the first one is returned.
|
PRINT WEAP.Branch("\Demand
Sites").Children.Item(2).Name PRINT WEAP.Branch("\Demand
Sites").Children.Item("Industry
East").FullName PRINT WEAP.DemandSites("Industry East").FullName PRINT WEAP.DemandSites("South City").Descendants("Showers").FullName |
NameList: Get a list of branch names separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only. |
'Create an array of all the Demand Site names, using the Visual Basic Split function DemandSiteArray = Split(WEAP.DemandSites.NameList, ",") |
Reverse: Reverse the list of branches. |
' Get the list of Weaping River nodes from downstream to upstream. FOR EACH Node in WEAP.Rivers("Weaping River").RiverNodes.Reverse ... |
WEAPBranch Properties and Methods |
Example (using VB script) | ||||||||||||||||||||||||||||||||||||||||||
ActiveInCurrentAccounts: Set or get whether the branch is active in the Current Accounts. The following types can be set as not active in the Current Accounts (all other types are always active in the Current Accounts): Demand Site, Catchment, Wastewater Treatment Plant, Groundwater Node, Reservoir, Other Supply, Transmission Link, Return Flow Link, Run of River Hydro, Diversion. |
WEAP.Branch("\Demand Sites\South City").ActiveInCurrentAccounts = FALSE FOR EACH Branch IN WEAP.Branch("\Demand
Sites").Children | ||||||||||||||||||||||||||||||||||||||||||
AddChild(NewName): Create a new branch named NewName on the Data Tree under the current branch. Only works for branches under Demand Sites and Catchments, Key Assumptions or Other Assumptions. Returns the new branch. If a branch under the current branch with that name already exists, a new one will not be created -- the existing branch will be returned. |
' Copy structure and data from catchment Agriculture West to catchment Agriculture North SET AgNorthBranch = WEAP.Branch("\Demand Sites and Catchments\Agriculture North") FOR EACH AgWestCrop IN WEAP.Branch("\Demand
Sites and Catchments\Agriculture West").Children | ||||||||||||||||||||||||||||||||||||||||||
AddChildren(NewNames): Create branches on the Data Tree under the current branch with names from the comma separated list in NewNames. Only works for branches under Demand Sites and Catchments, Key Assumptions or Other Assumptions. If a branch under the current branch with a name already exists, a new one will not be created. |
WEAP.Branch("\Demand Sites\West City").AddChildren("West District, East District, North District, South District") | ||||||||||||||||||||||||||||||||||||||||||
AddPoint(X, Y, AddBefore): Add a point to the line (river, diversion, transmission link, return flow link, runoff/infilltration link) at location X, Y. If optional integer parameter AddBefore is given, add before this point (numbered 1 to NumPoints). If not given, add at end (rivers and diversions) or just before the end (links). |
| ||||||||||||||||||||||||||||||||||||||||||
Children: Get the collection of all branches immediately underneath this branch. See WEAPBranches for details. See also WEAPBranch.Descendants and WEAPBranch.Leaves. Read only. |
' Compare Children, Descendants and Leaves: Print "Children" Print "Descendants" Print "Leaves" | ||||||||||||||||||||||||||||||||||||||||||
ConnectedGroundwater: For river reaches, transmission links, return flow links and reservoirs, get or set the groundwater node that it is connected to, if any (for losses to or gains from groundwater). For get, return an empty branch (ConnectedGroundwater.ID = 0) if no connection. To set no connection, call with an empty string (""). |
' List all nodes or reaches that
have connections to groundwater ' Connect
Central Reservoir to North Aquifer ' Connect Central Reservoir to the
first groundwater node ' Remove GW connection from Central
Reservoir | ||||||||||||||||||||||||||||||||||||||||||
CopyData(SourceBranch): Copy all data from SourceBranch to the current branch. SourceBranch is a WEAPBranch object, not the name of a branch. |
' Create \Demand Sites\South City\Suburban, copying structure and data from \Demand Sites\South City\Single Family SET SuburbanBranch = WEAP.Branch("\Demand Sites\South City").AddChild("Suburban") FOR EACH SingleFamilyBranch IN WEAP.Branch("\Demand
Sites\South City\Single Family").Children | ||||||||||||||||||||||||||||||||||||||||||
Delete: Delete the branch and any associated schematic objects. If the branch has any children, they will also be deleted. You cannot delete Schematic objects if the Schematic is locked. You cannot delete catchments or rivers created in Catchment Delineation Mode if Catchment Delineation Mode is not currently on. You cannot delete a branch in the Results View or Scenario Explorer View. |
' Delete all key assumptions FOR EACH Br IN Branch("\Key
Assumptions").Children ' Delete each demand site that does not have any branches underneath FOR EACH Br IN Branch("\Demand
Sites").Children ' Delete all reservoirs FOR EACH Br IN WEAP.Reservoirs | ||||||||||||||||||||||||||||||||||||||||||
Descendants: Get the collection of all branches at all levels underneath this branch. The list has a "depth first" ordering -- a branch's children are ordered before its siblings. Returns a WEAPBranches collection. See also WEAPBranch.Children and WEAPBranch.Leaves. Read only.
|
FOR EACH Br IN WEAP.Branch("\Key Assumptions").Descendants PRINT Br.FullName & " = " & Br.Variable("Annual Activity Level").Expression NEXT | ||||||||||||||||||||||||||||||||||||||||||
DownstreamNodes(IncludeOffstreamNodes, IncludeLinks, ForceSameRiver, MaxSteps): Gets the WEAPBranches collection of all nodes downstream of this branch, which must be a river node. If IncludeOffstreamNodes is True (optional, default is False), include Demand Sites and Catchments that withdraw from the river downstream. If IncludeLinks is True (optional, default is False), include River Reaches, and, if IncludeOffstreamNodes is also True, Transmission Links. If ForceSameRiver is True (optional, default is False), do not show nodes on other downstream rivers. (If IncludeOffstreamNodes is True, offstream nodes are also included.) If MaxSteps is greater than zero (optional, default is zero), only go up that many steps before stopping. If IncludeLinks is true, each node and link count as separate steps. See also UpstreamNodes. Read only. |
' List all Demand Sites downstream of Central Reservoir FOR EACH Br IN WEAP.Branch("Central Reservoir").DownstreamNodes(TRUE).FilterByType("Demand Site") PRINT Br.Name & " is downstream of Central Reservoir" NEXT ' List all river nodes up to 4 steps downstream of Central Reservoir FOR EACH Br IN WEAP.Branch("Central Reservoir").DownstreamNodes(FALSE, FALSE, FALSE, 4) PRINT Br.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
FirstNode: Get first node on the river. Can be called for a river branch, or any node or reach on a river. |
PRINT "The first node on Weaping River is " + WEAP.Rivers("Weaping River").FirstNode.Name | ||||||||||||||||||||||||||||||||||||||||||
FirstReach: Get first reach on the river. Can be called for a river branch, or any node or reach on a river. |
PRINT "The first reach on Weaping River is " + WEAP.Rivers("Weaping River").FirstReach.Name | ||||||||||||||||||||||||||||||||||||||||||
FullName: Get the full path of the current branch. Each level is separated by the "\" character. (e.g. Demand Sites\South City) Read only. |
FOR EACH Br IN WEAP.Branches | ||||||||||||||||||||||||||||||||||||||||||
HasTag(TagName): Set or get whether the branch has this tag. Branch.HasTag(TagName) is equivalent to Branch.Tags.Exists(TagName) |
IF WEAP.Branch("\Demand Sites\South City").HasTag("Agriculture") THEN PRINT "South City has agriculture tag" WEAP.Branch("\Demand Sites\South City").HasTag("Agriculture") = FALSE ' Turn off all catchments that are not in the American River Basin FOR EACH Br in WEAP.Catchments Br.ActiveInCurrentAccounts = Br.HasTag("American River Basin") NEXT | ||||||||||||||||||||||||||||||||||||||||||
HasTagCategory(TagCategoryName): Are any of these tags in this category? |
FOR EACH Br in WEAP.Catchments Br.ActiveInCurrentAccounts = Br.HasTagCategory("Upper Watersheds") NEXT | ||||||||||||||||||||||||||||||||||||||||||
HeadflowNode: Get or set the headflow node for a diversion, e.g., "Supply and Resources\River\Weaping River\Diversions\Grand Canal Outflow". Returns a WEAPBranch object -- use WEAPBranch.IsValid to test if valid (connected) or not (not connected). When setting, the node must already exist, and you can use either a WEAPBranch object or the branch's name. Set to "" (empty string) to disconnect. As a shortcut, you can give just the name of the node, e.g., "Grand Canal Outflow" |
SET HeadflowNode = WEAP.Branch("Supply and Resources\River\Grand Canal").HeadflowNode IF HeadflowNode.IsValid THEN WEAP.Branch("Supply and Resources\River\Grand Canal").HeadflowNode = "Supply and Resources\River\Weaping River\Diversions\Grand Canal Outflow" | ||||||||||||||||||||||||||||||||||||||||||
ID: Get the internal unique numeric ID of the branch. Each branch in the tree has a unique ID. It is not displayed in WEAP's normal interface but may be useful when automating WEAP. All valid branches have ID > 0, so you use the test Branch.ID = 0 to determine if a Branch reference is valid. Read only. |
FOR EACH Branch IN WEAP.Branches | ||||||||||||||||||||||||||||||||||||||||||
InflowLinks: Gets the WEAPBranches collection of all links that flow into this node, for example, for a Demand Site this will be all of its transmission links. For a river node, it will include its upstream reach. Read only. |
' List all transmission links that flow into Industry North FOR EACH Br in WEAP.DemandSites("Industry North").InflowLinks Print Br.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
InflowNodes: Gets the WEAPBranches collection of all nodes that flow into this node, for example, for a Demand Site this will be all of its sources (river withdrawal, groundwater, local reservoir, other local supply). Read only. |
' List the supplies for each demand site FOR EACH Br IN WEAP.DemandSites FOR EACH SupplyBr in Br.InflowNodes Print SupplyBr.Name & " supplies " & Br.Name NEXT NEXT ' List demand sites that flow into wastewater treatment plants FOR EACH WTP IN WEAP.WastewaterTreatmentPlants FOR EACH DS in WTP.InflowNodes Print WTP.Name & " receives wastewater from " & DS.Name NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
IsLine: Returns true if the branch represents a line object on the Schematic (River, Diversion, River Reach, Transmission Link, Return Flow Link, or Runoff/Infiltration Link). Read only. |
' Print GIS X,Y coordinates for all lines and nodes on the Schematic FOR EACH Branch IN WEAP.Branches IF Branch.IsNode THEN Print Branch.FullName & ": (" & Branch.X & ", " & Branch.Y & ")" ELSEIF Branch.IsLine THEN ' GIS coordinates of start and end points of line PRINT Branch.FullName & ": (" & Branch.X & ", " & Branch.Y & ") - (" & Branch.X2 & ", " & Branch.Y2 & ")" END IF NEXT | ||||||||||||||||||||||||||||||||||||||||||
IsNode: Returns true if the branch represents a node on the Schematic (Demand Site, Catchment, Groundwater node, Local Reservoir, Other Local Supply, Wastewater Treatment Plant or any river node). Read only. |
' Print GIS X,Y coordinates for all lines and nodes on the Schematic FOR EACH Branch IN WEAP.Branches IF Branch.IsNode THEN Print Branch.FullName & ": (" & Branch.X & ", " & Branch.Y & ")" ELSEIF Branch.IsLine THEN ' GIS coordinates of start and end points of line PRINT Branch.FullName & ": (" & Branch.X & ", " & Branch.Y & ") - (" & Branch.X2 & ", " & Branch.Y2 & ")" END IF NEXT | ||||||||||||||||||||||||||||||||||||||||||
IsRiverNode: Returns true if the branch represents a node on a river. Read only. |
' List all river nodes FOR EACH Br IN WEAP.Branches IF Br.IsRiverNode THEN Print Br.TypeName & ": " & Br.FullName END IF NEXT | ||||||||||||||||||||||||||||||||||||||||||
IsValid: Return TRUE if the WEAPBranch object is assocaited with a valid WEAP branch. Read only |
IF WEAP.Branch("Supply and Resources\River\Blue River").TailflowNode.IsValid THEN PRINT "Blue River is Connected" ELSE PRINT "Blue River is Not connected" END IF | ||||||||||||||||||||||||||||||||||||||||||
IsVisible: Returns true if the branch is visible on the tree. River category branches with no children will not be visible. For example, in Weaping River Basin, Blue River does not have any reservoirs -- therefore, the Reservoirs branch underneath Blue River will not be visible. |
IF WEAP.Branch("\Supply and
Resources\River\Blue River\Reservoirs").IsVisible THEN | ||||||||||||||||||||||||||||||||||||||||||
LastNode: Get last node on the river. Can be called for a river branch, or any node or reach on a river. |
PRINT "The last node on Weaping River is " + WEAP.Rivers("Weaping River").LastNode.Name | ||||||||||||||||||||||||||||||||||||||||||
LastReach: Get last reach on the river. Can be called for a river branch, or any node or reach on a river. |
PRINT "The last reach on Weaping River is " + WEAP.Rivers("Weaping River").LastReach.Name | ||||||||||||||||||||||||||||||||||||||||||
Leaves: Gets the WEAPBranches collection of all leaves underneath this branch. (A leaf is the lowest level, with no children of its own.) See also WEAPBranch.Children and WEAPBranch.Descendants. Read only. |
' Print all Water Use Rate expressions (they are only at the lowest level branches for each demand site) FOR EACH DS IN WEAP.DemandSites FOR EACH Br in DS.Leaves PRINT Br.FullName & ": Annual Water Use Rate = " & Br.Variable("Annual Water Use Rate").Expression NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
Level: Get the level of the branch in the tree, where the top level (e.g., Key Assumptions, Demand Sites, Supply and Resources) equals one. Read only. |
FOR EACH Br IN WEAP.Branches PRINT STRING(Br.Level * 4, " ") & Br.Order & ": " & Br.Name NEXT | ||||||||||||||||||||||||||||||||||||||||||
MapLabel: Set or get the map label for the node on the schematic. You may not change the name of links (transmission, return flow, runoff/infiltration). |
PRINT WEAP.Branch("\Demand Sites").Children(2).MapLabel WEAP.Branch("Industry East").MapLabel = "Industry;Southeast" ' Change the map label for Industry Southeast to "Industry;Southeast" (the semicolon denotes a line break) | ||||||||||||||||||||||||||||||||||||||||||
Name: Set or get the name of the branch. You may not change the name of links (transmission, return flow, runoff/infiltration). |
PRINT WEAP.Branch("\Demand Sites").Children(2).Name WEAP.Branch("Industry East").Name = "Industry Southeast" ' Change Industry East's name to "Industry Southeast" | ||||||||||||||||||||||||||||||||||||||||||
NodeAbove: For river nodes or reaches, gets the WEAPBranch for the river node above this node or reach. (The NodeAbove the first node or reach on a connected diversion is the diversion node on the main river.) For transmission links, return flow links or catchment runoff links, gets the WEAPBranch for the source node. Returns an empty branch (Branch.NodeAbove.ID = 0) if branch is not a river node, river reach, transmission link, return flow link or catchment runoff link, or is the first node or reach on the river. Read only. |
' List all river reaches downstream of a reservoir. (TypeID = 16 is a reach, TypeID = 4 is a reservoir) FOR EACH River IN WEAP.Branch("Supply and Resources\River").Children FOR EACH RiverType IN River.Children FOR EACH Child IN RiverType.Children IF (Child.TypeID = 16) and (Child.NodeAbove.TypeID = 4) THEN Print Child.FullName END IF NEXT NEXT NEXT ' Lists all transmission links whose source is groundwater. FOR EACH ToBranch IN WEAP.Branch("\Supply and Resources\Transmission Links").Children FOR EACH FromBranch IN ToBranch.Children IF FromBranch.NodeAbove.TypeID = 3 THEN ' TypeID = 3 is a groundwater node PRINT FromBranch.FullName END IF NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
NodeBelow: For river nodes or reaches, gets the WEAPBranch for the river node below this node or reach. (The NodeBelow the last node or reach on a river or diversion is the tributary inflow node on the downstream river.) For transmission links, return flow links or catchment runoff links, gets the WEAPBranch for the destination node. Returns an empty branch (Branch.NodeBelow.ID = 0) if branch is not a river node, river reach, transmission link, return flow link or catchment runoff link, or is already the last node or reach on the river. Read only. |
' List all river reaches upstream of a tributary inflow node. (TypeID = 16 is a reach, TypeID = 13 is a tributary inflow node) FOR EACH River IN WEAP.Branch("Supply and Resources\River").Children NEXT ' Lists all transmission links, including the source and destination. FOR EACH ToBranch IN WEAP.Branch("\Supply and Resources\Transmission Links").Children FOR EACH FromBranch IN ToBranch.Children PRINT FromBranch.FullName & " GOES FROM " & FromBranch.NodeAbove.FullName & " TO " & FromBranch.NodeBelow.FullName NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
Note: Set or get the note associated with the branch in plain text format. If you want to set or get the note in rich text format, which includes text formatting codes and non-text elements such as graphics, use the NoteAsRTF property instead. |
WEAP.Branch("\Demand Sites\South City").Note = "South City is a city on the banks of the Weaping River" FOR EACH Br IN WEAP.Branches IF Br.Note <> "" THEN PRINT "*************** Notes for " & Br.FullName & ": " PRINT Br.Note END IF NEXT | ||||||||||||||||||||||||||||||||||||||||||
NoteAsRTF: Set or get the note associated with the branch, in rich text format. If you want to set or get the note in plain text format, without text formatting codes and non-text elements such as graphics, use the Note property instead. |
Branch("\Demand Sites\Agriculture North").NoteAsRTF = Branch("\Demand Sites\Industry North").NoteAsRTF
' Save formatted note as Rich Text Format, which can be opened in Microsoft Word SET fso = CreateObject("Scripting.FileSystemObject") SET f = fso.CreateTextFile("Notes.rtf", True) f.Write Branch("\Demand Sites\Industry North").NoteAsRTF f.Close SET f = Nothing SET fso = Nothing | ||||||||||||||||||||||||||||||||||||||||||
NumChildren: Get the number of children below the branch, if any. |
| ||||||||||||||||||||||||||||||||||||||||||
NumPoints: Get the number of points on the line (river, diversion, transmission link, return flow link, runoff/infilltration link). |
PRINT WEAP.Branch("Supply and Resources\River\Weaping River").NumPoints PRINT WEAP.Branch("Supply and Resources\Transmission Links\to Agriculture North\from North Aquifer").NumPoints | ||||||||||||||||||||||||||||||||||||||||||
Order: Get the order of the branch among its siblings, where the order of the first sibling is one. Read only. |
FOR EACH Br IN WEAP.Branches PRINT STRING(Br.Level * 4, " ") & Br.Order & ": " & Br.Name NEXT | ||||||||||||||||||||||||||||||||||||||||||
OutflowLinks: Gets the WEAPBranches collection of all links that flow out of this node, for example, for a Demand Site this will be all its return flow links. For a river node, it will include its downstream reach. Read only.
|
' List all return flow links that flow out of Industry North FOR EACH Br in WEAP.DemandSites("Industry North").OutflowLinks Print Br.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
OutflowNodes: Gets the WEAPBranches collection of all nodes that flow out of this node, for example, for a Demand Site this will be all the destinations for its return flow links. Read only. |
' List all wastewater destinations for Industry North FOR EACH Br in WEAP.DemandSites("Industry North").OutflowNodes Print Br.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
Parent: Get the WEAPBranch object for the parent of the current branch. Read only. |
PRINT WEAP.Branch("\Demand Sites\South City").Parent.Name ' This will be "Demand Sites" | ||||||||||||||||||||||||||||||||||||||||||
ParentID: Get the numeric ID of the Parent of the current branch. Equivalent to Branch.Parent.ID. Read only. |
IF Branch.ParentID
= WEAP.Branch("\Demand Sites").ID THEN | ||||||||||||||||||||||||||||||||||||||||||
PriorityOnTransmissionLink: Set or get whether the demand priority is entered on the transmission link. If not, the demand priority will be entered on the demand site or catchment, and the supply preference will be entered on the transmission link. Can be used only on Demand Sites, Catchments or Transmission Link branches. When used on a Transmission Link, it will set PriorityOnTransmissionLink for the Demand Site or Catchment to which the Transmission Link goes. |
WEAP.Branch("\Demand Sites\South City").PriorityOnTransmissionLink = FALSE WEAP.Branch("\Supply and Resources\Transmission Links\to Agriculture West\from West Aquifer").PriorityOnTransmissionLink = TRUE FOR EACH Branch IN WEAP.Branch("\Demand
Sites").Children ' Set value for "Demand Priority" or "Supply Preference," depending on setting of PriorityOnTransmissionLink IF WEAP.Branch("\Supply and Resources\Transmission Links\to Agriculture West\from West Aquifer").PriorityOnTransmissionLink = TRUE THEN WEAP.Branch("\Supply and Resources\Transmission Links\to Agriculture West\from West Aquifer").Variables("Demand Priority").Expression = 3 ELSE WEAP.Branch("\Supply and Resources\Transmission Links\to Agriculture West\from West Aquifer").Variables("Supply Preference").Expression = 2 END IF | ||||||||||||||||||||||||||||||||||||||||||
ReachAbove: Gets the WEAPBranch for the river reach above this node or reach. (The ReachAbove the first node or reach on a connected diversion is the reach above the diversion node on the main river.) Returns an empty branch (Branch.ReachAbove.ID = 0) if branch is not a river node or reach, or is the first reach on the river or unconnected diversion. Read only. |
' List all river reaches immediately upstream of a reservoir FOR EACH RiverRes in WEAP.RiverReservoirs PRINT RiverRes.ReachAbove.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
ReachBelow: Gets the WEAPBranch for the river reach below this node or reach. (The ReachBelow the last node or reach on a river or diversion is the reach below the tributary inflow node on the downstream river.) Returns an empty branch (Branch.ReachBelow.ID = 0) if branch is not a river node or reach, or is already the last reach on the river or diversion that does not flow into another river or diversion. Read only. |
' List all river reaches immediately downstream of a reservoir FOR EACH RiverRes in WEAP.RiverReservoirs PRINT RiverRes.ReachBelow.FullName NEXT | ||||||||||||||||||||||||||||||||||||||||||
RiverNodes: Get list of nodes for river, in order from upstream to downstream. Can be called for a river branch, or any node or reach on a river. |
FOR EACH River in WEAP.Rivers Print River.Name + " Nodes:" FOR EACH Br in River.RiverNodes PRINT " " & Br.RiverOrder & ": " & Br.FullName NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
RiverReaches: Get list of reaches for river, in order from upstream to downstream. Can be called for a river branch, or any node or reach on a river. |
FOR EACH River in WEAP.Rivers Print River.Name + " Reache:" FOR EACH Br in River.RiverReaches PRINT " " & Br.RiverOrder & ": " & Br.FullName NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
RiverNodesAndReaches: Get list of nodes and reaches for river, in order from upstream to downstream. Can be called for a river branch, or any node or reach on a river. |
FOR EACH River in WEAP.Rivers Print River.Name + " Nodes and Reaches:" FOR EACH Br in River.RiverNodesAndReaches PRINT " " & Br.RiverOrder & ": " & Br.FullName NEXT NEXT | ||||||||||||||||||||||||||||||||||||||||||
ShapeID: Get the internal numerical ID of the schematic object (e.g., Demand Site or Reservoir) associated with the branch. To match this ID to a GIS shape, look at the ObjID attribute in the WEAPNodes or WEAPArcs shape files. Note: This is a different internal ID code from the Branch ID (Branch.ID). Not every branch will have a corresponding schematic object, e.g., "\Demand Sites," in which case ShapeID = 0. Each schematic object has a unique ShapeID, although several branches can be associated with one shape, e.g., WEAP.Branch("\Supply and Resources\Return Flows\from Agriculture North\to North Aquifer").ShapeID is the same as WEAP.Branch("\Water Quality\Pollutant Decrease in Return Flows\from Agriculture North\to North Aquifer").ShapeID. Read only. |
FOR EACH Branch IN WEAP.Branches NEXT | ||||||||||||||||||||||||||||||||||||||||||
Split(NewNames, DoCopyData): Subdivide a branch, creating a new child for each name in the comma separated list NewNames. If parameter DoCopyData is TRUE (optional, defaults to TRUE), copy all data from the current branch to the new branches (except Activity Level and Area). Activity Unit for the new branches will be set to percent. |
CALL WEAP.Branch("\Demand Sites\Industry North").Split("Manufacturing, Cooling") | ||||||||||||||||||||||||||||||||||||||||||
StartupYear: Set or get the startup year for the branch object, in the currently active scenario. If startup year is 0, the branch is not active in the scenario. Can only be changed if the branch is already set as Not Active In Current Accounts. (This setting can be changed with the ActiveInCurrentAccounts property--see above.) Note: Some objects (e.g., rivers) are always active and cannot be set to start up after the Base Year. |
WEAP.ActiveScenario = "Supply Measures" SET BrNorthRes = WEAP.Branch("\Supply and Resources\River\Weaping River\Reservoirs\North Reservoir") IF BrNorthRes.StartupYear = 0 THEN BrNorthRes.StartupYear = WEAP.BaseYear + 5 | ||||||||||||||||||||||||||||||||||||||||||
Tags: Get collection of tags for branch, if any. |
' Print list of all branches and the tags each has FOR EACH Br in WEAP.Branches Print Br.FullName & ": " & Br.Tags.NameList NEXT | ||||||||||||||||||||||||||||||||||||||||||
TailflowNode: Get or set the tailflow node for a tributary or diversion, e.g., "Supply and Resources\River\Weaping River\Tributary Inflow\Blue River Inflow". Returns a WEAPBranch object -- use WEAPBranch.IsValid to test if valid (connected) or not (not connected). When setting, the node must already exist, and you can use either a WEAPBranch object or the branch's name. Set to "" (empty string) to disconnect. As a shortcut, you can give just the name of the node, e.g., "Blue River Inflow." |
WEAP.Branch("Supply and Resources\River\Blue River").TailflowNode = "Supply and Resources\River\Weaping River\Tributary Inflow\Blue River" IF WEAP.Branch("Supply and Resources\River\Blue
River").TailflowNode.IsValid THEN | ||||||||||||||||||||||||||||||||||||||||||
TypeID: Get the numeric code indicating the type of branch. See list in TypeName below. Read only. |
FOR EACH Branch IN WEAP.Branch("\Demand
Sites").Children NEXT | ||||||||||||||||||||||||||||||||||||||||||
TypeName: Get the name of the type of branch. Read only. Valid branch names and their associated ID's:
|
FOR EACH Branch IN WEAP.Branch("\Demand Sites").Children IF Branch.TypeName = "Demand Site" THEN ' Demand site or catchment? ... END IF NEXT ' Note: This is equivalent to FOR EACH Branch IN WEAP.DemandSites | ||||||||||||||||||||||||||||||||||||||||||
UpstreamNodes(IncludeOffstreamNodes, IncludeLinks, ForceSameRiver, MaxSteps): Gets the WEAPBranches collection of all nodes upstream of this branch, which must be a river node. If IncludeOffstreamNodes is True (optional, default is False), include Demand Sites, Catchments and Wastewater Treatment Plants that return to the river upstream. If IncludeLinks is True (optional, default is False), include River Reaches, and, if IncludeOffstreamNodes is also True, Return Flow and Runoff/Infiltration Links. If ForceSameRiver is True (optional, default is False), do not show nodes on other upstream rivers. (If IncludeOffstreamNodes is True, offstream nodes are also included.) If MaxSteps is greater than zero (optional, default is zero), only go up that many steps before stopping. If IncludeLinks is true, each node and link count as separate steps. See also DownstreamNodes. Read only. |
' Tag all nodes upstream of Gauge 283401, including catchments, with the tag "American River Basin" FOR EACH Br in WEAP.Branch("Gauge 283401").UpstreamNodes(True) Br.HasTag("American River Basin") = True NEXT ' List all catchments upstream of Gauge 283401 FOR EACH Br in WEAP.Branch("Gauge 283401").UpstreamNodes(True).FilterByType("Catchment") Print Br.Name NEXT ' List all tributaries that flow into tributary node "Trib Node 5" SET TribNode = WEAP.Branch("Blue River Trib Node") FOR EACH Br IN TribNode.UpstreamNodes(False, False, False, 1) ' just look one step away IF Br.River.ID <> TribNode.River.ID THEN ' Do not include main river Print Br.River.Name END IF NEXT
| ||||||||||||||||||||||||||||||||||||||||||
Variable(VariableName): Get the named variable for this branch. See WEAPVariable for details. Read only |
WEAP.Branch("\Demand Sites\South City").Variable("Consumption").Expression = 40 | ||||||||||||||||||||||||||||||||||||||||||
VariableExists(VariableName): Returns true if the specified variable exists for this branch. Branch.VariableExists(VariableName) is equivalent to Branch.Variables.Exists(VariableName). Read only. |
' Set the wind speed for every catchment
to be 3.3 m/s | ||||||||||||||||||||||||||||||||||||||||||
Variables: Get the collection of all variables associated with this branch. See WEAPVariables for details. Read only |
FOR i = 1 to WEAP.Branch("\Demand
Sites\South City").Variables.Count; WEAP.Branch("\Demand Sites\South City").Variables("Consumption").Expression = 30 | ||||||||||||||||||||||||||||||||||||||||||
X: Get the GIS X coordinate of the schematic object associated with the branch. If the schematic object is a line, this will be the X coordinate of the starting point of the line. If the Schematic GIS layers are unprojected (WGS84), then X is longitude. Read only. |
' Print each demand site's name and X,Y GIS coordinates For Each Br in WEAP.Branch("\Demand Sites and Catchments").Children Print Br.FullName & ": " & Br.X & ", " & Br.Y Next | ||||||||||||||||||||||||||||||||||||||||||
X2: If the schematic object associated with the branch is a line (river, diversion, river reach, transmission link, return flow link or runoff/infiltration link), get the GIS X coordinate of the endpoint of the line. If the Schematic GIS layers are unprojected (WGS84), then X is longitude. Read only. |
See example for IsLine above. | ||||||||||||||||||||||||||||||||||||||||||
Y: Get the GIS Y coordinate of the schematic object associated with the branch. If the schematic object is a line, this will be the Y coordinate of the starting point of the line. If the Schematic GIS layers are unprojected (WGS84), then Y is latitude. Read only. |
See example for X above. | ||||||||||||||||||||||||||||||||||||||||||
Y2: If the schematic object associated with the branch is a line (river, diversion, river reach, transmission link, return flow link or runoff/infiltration link), get the GIS Y coordinate of the endpoint of the line. If the Schematic GIS layers are unprojected (WGS84), then Y is latitude. Read only. |
See example for IsLine above. |