WEAPFavorite and WEAPFavorites API Classes

The WEAPFavorite class represents a single WEAP "favorite" (saved report from the Results View), whereas WEAPFavorites is the collection of all favorites in the active area.

The WEAPFavorites collection is a property of the WEAPApplication class:

  1. WEAPApplication.Favorites, e.g., WEAP.Favorites

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

  1. WEAPFavorites(FavoriteName or Index), specifying either the name of the favorite or a number from 1 to WEAPApplication.Favorites.Count, e.g., WEAP.Favorites("Groundwater Storage") or WEAP.Favorites(1)

  2. Iterate through the collection of favorites, e.g., For Each Favorite in WEAP.Favorites

WEAPFavorites Properties and Methods

Example (using VB script)

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

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

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

IF WEAP.Favorites.Exists("Groundwater Storage") THEN
WEAP.Favorites("Groundwater Storage").Load
END IF

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

PRINT WEAP.Favorites.Item(1).Name
PRINT WEAP.Favorites(1).Name

WEAP.Favorites("Groundwater Storage").Load
WEAP.Favorites("Demand\Unmet Demand").Load   ' Favorite "Unmet Demand" is in the folder "Demand"

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

PRINT "Favorites: " & WEAP.Favorites.NameList

 

WEAPFavorite Properties and Methods

Example (using VB script)

Delete: Delete the favorite.

WEAP.Favorites("Demand\Unmet Demand").Delete

Folder: Get the name of the folder the favorite is in.  If it is not in a folder, it returns an empty string.  Read only.

FOR Each Fav in WEAP.Favorites

   PRINT Fav.Folder

END IF

Load: Load the favorite.  Will calculate and change to the Results View if necessary.

 

FOR Each Fav in WEAP.Favorites

   Fav.Load

   WEAP.ExportResults("C:\" & Fav.Name, TRUE, FALSE, TRUE, TRUE)

END IF

Name: Get the name of the favorite. If the favorite is in a folder, the name will include the folder, e.g., Folder\Name.  Read only.

FOR Each Fav in WEAP.Favorites

   PRINT Fav.Name

END IF

Note: Set or get the favorite's note.

 

WEAP.Favorites("Groundwater Storage").Note = "While the Demand Measures and Supply Measures each slow the depletion of groundwater, only the Integrated Measures scenario stops the decline."