WEAPTimestep and WEAPTimesteps API Classes

The WEAPTimestep class represents a single WEAP Timestep, whereas WEAPTimesteps is the collection of all Timesteps in the active area.

The WEAPTimesteps collection is a property of the WEAPApplication class, e.g., WEAP.Timesteps

You can get access to a WEAPTimestep in two different ways:

  1. WEAPApplication.Timesteps(TimestepName or Index), specifying either the name of the Timestep or a number from 1 to WEAPApplication.Timesteps.Count, e.g., WEAP.Timesteps("January") or WEAP.Timesteps(1)

  2. Iterate through the collection of timesteps, e.g., For Each TS in WEAP.Timesteps

WEAPTimesteps Properties and Methods

Example (using VB script)

Count: Get the number of WEAP Timesteps in the active area. Read only.

FOR i = 1 to WEAP.Timesteps.Count;
  PRINT WEAP.Timesteps(i).Name
NEXT

Exists(TimestepName): Returns true if TimestepName exists.  Read only.

IF WEAP.Timesteps.Exists("Juli") THEN
...

Item(TimestepName or Index): Get the Timestep identified by name or index (from 1 to Timesteps.Count).  Item is the "default" property, and therefore is usually omitted. Thus, the first two examples to the right are equivalent.

PRINT WEAP.Timesteps.Item("January").NumDays
PRINT WEAP.Timesteps("January").NumDays
PRINT WEAP.Timesteps(1).Abbrev

NameList: Get a list of timesteps separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only.

PRINT "Timesteps: " & WEAP.Timesteps.NameList

 

WEAPTimestep Properties and Methods

Example (using VB script)

Abbrev: The abbreviation for the timestep, e.g., "Jan" for "January".

PRINT WEAP.Timesteps("January").Abbrev

CalendarIndex: Get the index of this timestep, from 1 to Timesteps.Count, where January is 1.  Note: This is equivalent to WEAP.WaterYearStart (which can also be used to set the first timestep).

PRINT WEAP.Timesteps("October").CalendarIndex  ' If FirstTimestep is October, then this = 10

ContainsLeapDay: True if the timestep contains February 29 and WEAP.IncludeLeapDays is true.  Read only.

PRINT WEAP.Timesteps("October").ContainsLeapDay   ' False

PRINT WEAP.Timesteps("February").ContainsLeapDay   ' True (if WEAP.IncludeLeapDays is true)

DaysBefore: Get the total number of days in the water year before this timestep. For example, if Read only.

PRINT WEAP.Timesteps("January").DaysBefore  ' If FirstTimestep is October, then this = 92 (October + November + December).  If FirstTimestep is January, then this = 0.

ID: Get the internal unique numeric ID of the timestep.  Each timestep has a unique ID.  It is not displayed in WEAP's normal interface but may be useful when automating WEAP.  Read only.

 

Name: Get the name of the Timestep. Read only.

FOR Each Timestep in WEAP.Timesteps
PRINT Timestep.Name

NEXT

Index: Get the index of this timestep, from 1 to Timesteps.Count, where FirstTimestep is 1.  For example, if FirstTimestep is October, then Timesteps("October").Index = 1.  Read only.

PRINT WEAP.Timesteps("October").Index  ' If FirstTimestep is October, then this = 1

NumDays: Get the number of days in the timestep, which could be a fractional number.  Read only.

PRINT WEAP.Timesteps(2).NumDays  ' If FirstTimestep is October, then this = 30 (Timestep 2 is November)

ResultsShown: Set or get whether the Timestep's results will be shown in the Results View (calculating if necessary).

WEAP.ActiveTimestep.ResultsShown = TRUE