WEAPApplication API Class

The WEAPApplication class contains top-level properties and methods, including access to all other classes.

Note: in the following examples, a reference to WEAP, as in WEAP.ActiveArea, assumes that there is an object named WEAP of class WEAPApplication. This can be created in VBScript by:

SET WEAP = CreateObject("WEAP.WEAPApplication")

However, this is not necessary when running scripts inside WEAP (e.g. using the Call function in an expression, from the menu (Advanced, Scripting, Run), or from the script editor) because an object named WEAP is automatically added to the internal scripting environment.

WEAPApplication Properties and Methods

Example (using VB script)

ActiveArea: Set or get the active WEAP area (i.e., dataset). Read or write.

WEAP.ActiveArea = "Weaping River Basin"   'Note: This is equivalent to WEAP.Areas("Weaping River Basin").Open

PRINT WEAP.ActiveArea.Name

ActiveScenario: Set or get the active scenario. Read or write.

WEAP.ActiveScenario = "Current Accounts"   ' set it using the scenario's name

WEAP.ActiveScenario = WEAP.Scenarios("Current Accounts")  ' or set it by getting a scenario object

Note: This is equivalent to WEAP.Scenarios("Current Accounts").Activate

PRINT WEAP.ActiveScenario.Name

Areas: Get the collection of all WEAP areas. See WEAPAreas for details. Read only.

WEAP.Areas("Weaping River Basin").Open

PRINT WEAP.Areas(1).Name

AreasDirectory: Gets the full path of the folder in which WEAP areas are stored, typically under My Documents. Read only.

PRINT WEAP.AreasDirectory

AreaSetting(Key, Section): Set or get a text value associated with a key (text).  Value is stored in file area.ini in the area subdirectory.  If Section is not specified, will look in section User.  The area.ini file can be a convenient place for the user to store settings that apply to one area.  WEAP-wide settings can also be saved--see Setting and DeleteSetting.

WEAP.AreaSetting("Custom hydrology model") = "SWAT"

WEAP.AreaSetting("Model directory", "SWAT") = "C:\Program Files\SWAT"

IF WEAP.AreaSetting("Custom hydrology model") = "SWAT" THEN

  ...

END IF

AutoCalc: Set or get the Auto Calculation setting. If AutoCalc is FALSE, WEAP will not calculate any expressions in the Data View. Read or write.

WEAP.AutoCalc = FALSE   ' Turn off automatic calculations

BaseYear: Set or get the first year of the study period. Read or write.

WEAP.BaseYear = 2000

PRINT WEAP.BaseYear

Branch(BranchNameOrID): Get the WEAPBranch object for the specified branch name or ID. Read only.  (ID is 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.)

WEAP.Branch("\Demand Sites\South City").Variables("Consumption").Expression = "30"

PRINT WEAP.Branch(176).Name

Branches: Get the collection of all visible branches in the tree. Returns a WEAPBranches object. Read only.

Set xla = CreateObject("Excel.Application")

xla.Visible = true

xla.ScreenUpdating = false

Set xlw = xla.Workbooks.Add

Set xls = xlw.sheets.add

r = 1

FOR EACH B in WEAP.Branches

   FOR EACH V in B.Variables

      IF not V.IsResultVariable THEN

        r = r + 1

        xls.Cells(r, 1).Value = B.FullName

        xls.Cells(r, 2).Value = V.Name

        xls.Cells(r, 3).Value = V.Expression

      END IF

   NEXT

NEXT       

BranchExists(BranchName): Check if a branch exists. Read only.

IF WEAP.BranchExists("\Demand Sites\South City") THEN
  WEAP.Branch("\Demand Sites\South City").Variables("Consumption").Expression = "30"
END IF

BranchVariable(BranchName:VariableName): Get the WEAPVariable object for the specified branch and variable. VariableName can be omitted if BranchName only has one variable (e.g., Key Assumptions branches have one variable). Note: This is equivalent to Branch(BranchName).Variables(VariableName). Read only.

WEAP.BranchVariable("\Demand Sites\South City:Consumption").Expression = "30"

Note: This is equivalent to Branch(BranchName).Variable(VariableName)

Calculate(LastYear, LastTimestep, AlwaysCalculate): Force WEAP to calculate all scenarios marked for calculation, even if WEAP thinks the calculations are up to date (unless optional parameter AlwaysCalculate is set to false). This is useful if you have changed values in an input file that WEAP is reading via ReadFromFile. If optional parameters LastYear and LastTime are given, only calculate up to that year and timestep.  Note: AlwaysCalculate = false is the same as calling WEAP.View = "Results," because that also only calculates scenarios needing calculation.

WEAP.Calculate

WEAP.Calculate(2000, 6)

WEAP.Calculate(0, 0, false)   ' Only calculate scenarios that need calculation

CalculationErrors: Get the number of WEAP calculation errors from the just-run WEAP calculation. Read only.

IF WEAP.CalculationErrors > 0 THEN PRINT WEAP.CalculationErrors, " calculation errors"

CalculationTime: Get the calculation time from the just-run WEAP calculation, in seconds. Read only.

PRINT WEAP.CalculationTime, " seconds to calculate"

CalcTS: Get the timestep being calculated.  Read only.

IF WEAP.CalcYear = WEAP.BaseYear and WEAP.CalcTS = WEAP.NumTimeSteps THEN
' Do something in the last timestep of the Current Accounts
END IF

CalcYear: Get the year being calculated.  Read only.

IF WEAP.CalcYear = WEAP.BaseYear THEN
Initialize
END IF

CalledByBranch: If the script containing this statement was called from an expression using the Call function, this will get the WEAPBranch object for the branch that made the call. Read only.

PRINT WEAP.CalledByBranch.FullName

CalledByScenario: If the script containing this statement was called from an expression using the Call function, this will get the WEAPScenario object for the scenario that made the call. Read only.

PRINT WEAP.CalledByScenario.Name

CalledByTimeStep: If the script containing this statement was called from an expression using the Call function, this will get the timestep number (from 1 to NumTimeSteps) for the timestep that made the call. Read only.

IF WEAP.CalledByTimeStep = 6 THEN

...

CalledByVariable: If the script containing this statement was called from an expression using the Call function, this will get the WEAPVariable object for the variable that made the call. Read only.

PRINT WEAP.CalledByVariable.Name

CalledByYear: If the script containing this statement was called from an expression using the Call function, this will get the year number (between BaseYear and EndYear) for the year that made the call. Read only.

IF WEAP.CalledByYear > WEAP.BaseYear THEN

...

DataExpression(BranchVariableName, InheritIfNecessary): Set or get the data expression for the branch:variable. Because a blank expression will default to the expression from the parent scenario, use FALSE for the optional parameter InheritIfNecessary to prevent inheriting from the scenario.

WEAP.DataExpression("\Demand Sites\South City:Annual Activity Level") = "Growth(3%)"

PRINT WEAP.DataExpression("\Demand Sites\South City:Annual Activity Level")

IF WEAP.DataExpression("\Demand Sites\South City:Annual Activity Level", FALSE) = "" THEN 'check if blank in active scenario
  WEAP.DataExpression("\Demand Sites\South City:Annual Activity Level") = "Growth(3%)"
END IF

DeleteAreaSetting(Key, Section): Delete a text value associated with a key (text) (previously saved by WEAP.AreaSetting), from file area.ini in the area subdirectory.  If Section is not specified, will look in section User.  The area.ini file can be a convenient place for the user to store settings that apply to one area.  WEAP-wide settings can also be saved--see Setting and DeleteSetting.

WEAP.DeleteAreaSetting("Custom hydrology model")

DeleteResults: Delete all results files for the active area.  This might speed up calculations, if the results file contain previously calculated results from many scenarios, but you only want to look at results for one or a few scenarios.

WEAP.DeleteResults

DeleteSetting(Key, Section): Delete a text value associated with a key (text) (previously saved by WEAP.Setting), from file weap.ini in the WEAP main directory.  If Section is not specified, will look in section User.  The weap.ini file can be a convenient place for the user to store settings that apply to all of WEAP.  Area-specific settings can also be saved--see AreaSetting and DeleteAreaSetting.

WEAP.DeleteSetting("PEST directory")

DictionaryVersion: Get the WEAP data dictionary version number. Read only.

PRINT "WEAP data dictionary version "; WEAP.DictionaryVersion

Directory: Get the directory where the WEAP program is located. Read only.

PRINT "WEAP is located in "; WEAP.Directory

DiscountRate: Get or set the area-wide discount rate (percent).  Can also be set in WEAP from the Main Menu: General, Units, Monetary.  Read or write.

WEAP.DiscountRate = 3     ' Sets discount rate to 3%

EndYear: Set or get the last year of the study period. Read or write.

WEAP.EndYear = 2020

PRINT WEAP.EndYear

ExportExpressions(NewWorkbook, ExportAllBranches, ExportAllVariables, ExportAllScenarios, ExportBlankExpressions, ExportInheritedExpressions, AutoFilter): Use this option to export to Excel some or all of the data expressions in WEAP. This process will allow you to link your WEAP expressions to Excel values for later import back into WEAP. See ImportExpressions for details of importing. In addition, Excel, with its filtering capabilities, provides a convenient way to view your data.  All parameters are True/False and are optional -- if omitted, all default to True, except for ExportBlankExpressions and ExportInheritedExpressions, which both default to False.  Can only be used in the Data View.  See Export Expressions to Excel for more information.

WEAP.ExportExpressions   ' export expressions for all branches, variables and scenarios to Excel

WEAP.ExportExpressions(True, False, True, False)    ' Export expressions for all variables for the current branch and scenario to Excel

If the filename has the .xls extension, the table will be exported to an Excel file. Otherwise, it will be exported to a CSV file.

ExportResults(CSVFilename, IncludeTitle, IncludeColumnTitles, Transpose, ReadFromFileFormat): Save active results table to a comma separated value (CSV) file. Will switch to Results View if necessary, calculating results as needed. If IncludeTitle = FALSE, do not include a title in the file. If IncludeColumnTitles = FALSE, do not have a row with column titles. If Transpose is TRUE, transpose the rows and columns.  If ReadFromFileFormat is TRUE, save in the format expected by the ReadFromFile function (one line per timestep).  IncludeTitle, IncludeColumnTitles, Transpose and ReadFromFileFormat are optional parameters; IncludeTitle and IncludeColumnTitles default to TRUE if omitted, whereas Transpose and ReadFromFileFormat default to FALSE if omitted.

ExportResults(ExcelFilename): Save active results table to an Excel (XLS) file. Will switch to Results View if necessary, calculating results as needed. If there are more than 256 columns (e.g., 30 years of monthly results would be 30*12 = 360 columns), the table will be transposed.

Note: ExportResults works in both the Results View and the Scenario Explorer View.

WEAP.ExportResults("C:\Groundwater.csv")

WEAP.ExportResults("C:\Groundwater.csv", FALSE)

WEAP.ExportResults("C:\Groundwater.csv", TRUE, FALSE)

WEAP.ExportResults("C:\Groundwater.csv", TRUE, FALSE, TRUE)

WEAP.ExportResults("C:\Groundwater.csv", TRUE, FALSE, TRUE, TRUE)

 

 

WEAP.LoadOverview("Default")

WEAP.ExportResults("C:\Overview.xls")

FirstTimeStep: Deprecated -- use WaterYearStart instead (which can get and set).  Get the index for the first timestep of the water year.

PRINT WEAP.FirstTimeStep    ' if the water year begins in October, this would be 10

WEAP.FirstTimeStep = 3      ' set the water year start to March

Note: FirstTimeStep is equivalent to Timesteps(1).CalendarIndex

ImportExpressions: Import expressions from current Excel worksheet.  Before using this option you must have created and opened a spreadsheet in Excel containing the data you wish to import. This spreadsheet must be strictly formatted with the names of branches, scenarios and variables as the rows of the spreadsheet. The only practical way to create such a spreadsheet is to first use the ExportExpressions API command (main menu: Edit, Export to Excel). Can only be used in the Data View.  See Import Expressions from Excel for more information.

WEAP.ImportExpressions

IncludeLeapDays: True if the timestep which includes February 29 will have an extra day in leap years.  Read only.

IF WEAP.IncludeLeapDays Then ...

IsCalculating: True if WEAP is calculating, False if not.  Read Only.

IF WEAP.IsCalculating Then ...

LoadFavorite(FavoriteName): Load predefined report format, which had been previously saved as a WEAP "favorite." Will switch to Results View if necessary, calculating results as needed.

WEAP.LoadFavorite("Groundwater Storage")

LoadOverview(OverviewName): Load previously saved WEAP "overview." Will switch to Scenario Explorer View if necessary, calculating results as needed. Tip: Once an overview has been loaded, you may use WEAP.ExportResults to save all the tables to a CSV or Excel file.

WEAP.LoadOverview("Default")

LogCalculationErrors: Get or set value -- if true, log all "calculation" errors and warnings to WEAP.LogFile.  Calculation errors are those that appear on the Messages tab in the Results View.

WEAP.LogCalculationErrors = TRUE

Logfile: Set or get the file to which errors and warnings are logged (only if Verbose is 0, 1 or 2).  Note: these errors and warning are not the same as "calculation" errors -- those that appear on the Messages tab in the Results View.

WEAP.Logfile = WEAP.Directory + "WEAPErrors.txt"

NumErrors: Get or reset the number of errors this session from using API property and method calls..

IF WEAP.NumErrors > 0 THEN PRINT WEAP.NumErrors; " Errors"

NumTimeSteps: Get the number of time steps in each year (e.g., 12). Read only.

PRINT WEAP.NumTimeSteps

Note: This is equivalent to WEAP.Timesteps.Count

PrevTSCalcTS: Integer: Get the timestep of the previous calculation timestep.  Read only

PRINT WEAP.BranchVariable("\Demand Sites\South City:Supplied").Value(WEAP.PrevTSCalcYear, WEAP.PrevTSCalcTS)

PrevTSCalcYear: Integer: Get the year of the previous calculation timestep.  Read only.

PRINT WEAP.BranchVariable("\Demand Sites\South City:Supplied").Value(WEAP.PrevTSCalcYear, WEAP.PrevTSCalcTS)

Print(Number or text): Prints a number or a text string.  Print statements are sent to the APIPrint.txt file.  This file is automatically monitored and displayed in WEAP's Script Editor.  

WEAP.Print("The current calculation year is " & WEAP.CalcYear)

PrintToFile(FileName, Number or text, Append): Prints a number or a text string to a named text file.  The value of the optional parameter Append will determine what WEAP will do if the file already exists: if Append is TRUE (or not specified), WEAP will add the number or text to the end of the existing file.  Otherwise, the file will be cleared before writing the number or text to it.

WEAP.PrintToFile("C:\Results.txt", "Results from scenario: " + WEAP.ActiveScenario.Name, TRUE)

WEAP.PrintToFile("C:\AreaCount.txt", WEAP.Areas.Count, FALSE)

ProgramDirectory: Gets the full path of the folder in which WEAP is installed. Read only.

PRINT WEAP.ProgramDirectory

ProgramStarted: Determine if WEAP has finished starting up. Can be used to make sure WEAP is loaded before continuing in the script. Read only.

WEAP = CreateObject("WEAP.WEAPApplication")
WHILE NOT WEAP.ProgramStarted
  ' do nothing
WEND

Registered: Returns true if WEAP is registered (licensed).  WEAP must be registered in order to save changes to data, or to use the API.  Read only.

IF Not WEAP.Registered THEN PRINT "Because WEAP is not registered, you cannot use the API"

ResultSetting: Make changes to settings for the currently displayed chart or table in the Results View.  The format is:  WEAP.ResultSetting(Attribute) = Value, e.g., WEAP.ResultSetting("XAxis") = "Year"

 

Attribute

Allowed Values

Variable

Result chart to load, e.g., "Water Demand"

XAxis

"Year" or "Scenario" or "Branch" or "Cost"

Legend

"Scenario" or "Branch" or "Cost" or "Pollutant"

Scenario

"All" or any of the scenario names

Year

"All" or "Year" or "Year1,Year2,..." or "Year1-Year2"

Month

"All" or "Month1" or "Month1,Month2,..." or "Month1-Month2"

Timestep

Same as Month

Branch

Full branch path, e.g., \Demand Sites\South City

Cost/Benefit Type

"All" or "Benefit" or "Capital Cost" or "Operating Cost"

Cost

Same as Cost/Benefit Type

WQ Constituent

"All" or any of the water quality constituents

Pollutant

Same as WQ Constituent

Chart Type

"Bar" or "Line" or "Step" or "Area" or "AreaWithLines" or "Pie" or "Surface"

Levels

1, 2, 3, 4 or 5  (levels of branches to display)

Annual Total

True or False

Monthly Average

True or False

Stacked

True or False

Group

True or False

Y=0

True or False

Exceedance

True or False

Log

True or False

Gridlines

True or False

Patterns

True or False

Line Symbols

True or False

3D

True or False

WEAP.ResultSetting("Variable") = "Inflows To Area"

WEAP.ResultSetting("Variable") = "Water Demand"

WEAP.ResultSetting("XAxis") = "Scenario"

WEAP.ResultSetting("XAxis") = "Year"

WEAP.ResultSetting("Legend") = "Scenario"

WEAP.ResultSetting("Legend") = "Branch"

WEAP.ResultSetting("Scenario") = "All"

WEAP.ResultSetting("Scenario") = "Demand Measures"

WEAP.ResultSetting("Scenario") = "Demand Measures, Supply Measures"

WEAP.ResultSetting("Scenario") = WEAP.Scenarios("Demand Measures")

FOR Scen IN WEAP.Scenarios
WEAP.ResultSetting("Scenario") = Scen

WEAP.ResultSetting("Year") = "All"

WEAP.ResultSetting("Year") = 2015

WEAP.ResultSetting("Year") = "2011,2013,2015"

WEAP.ResultSetting("Year") = "2011,2015-2017"

WEAP.ResultSetting("Month") = "All"

WEAP.ResultSetting("Month") = 3

WEAP.ResultSetting("Timestep") = "1-3,7-9"

WEAP.ResultSetting("Branch") = "\Demand Sites\South City"

FOR Br IN WEAP.Branches("\Demand Sites").Children
WEAP.ResultSetting("Branch") = Br

WEAP.ResultSetting("Cost") = "All"

WEAP.ResultSetting("Cost/Benefit Type") = "Capital Cost,Operating Cost"

WEAP.ResultSetting("Pollutant") = "All"

WEAP.ResultSetting("WQ Constituent") = "BOD"

WEAP.ResultSetting("Chart Type") = "Line"

WEAP.ResultSetting("Chart Type") = "Bar"

WEAP.ResultSetting("Chart Type") = "Step"

WEAP.ResultSetting("Chart Type") = "Area"

WEAP.ResultSetting("Chart Type") = "AreaWithLines"

WEAP.ResultSetting("Chart Type") = "Pie"

WEAP.ResultSetting("Levels") = 2

WEAP.ResultSetting("Annual Total") = True

WEAP.ResultSetting("Monthly Average") = True

WEAP.ResultSetting("Stacked") = True

WEAP.ResultSetting("Group") = True    ' Turn on grouping (smallest values grouped into "All Other")

WEAP.ResultSetting("Y=0") = True

WEAP.ResultSetting("Exceedance") = False

WEAP.ResultSetting("Log") = False

WEAP.ResultSetting("Gridlines") = False

WEAP.ResultSetting("Patterns") = True

WEAP.ResultSetting("Line Symbols") = True

WEAP.ResultSetting("3D") = False

ResultValue(BranchName:VariableName[Scale Unit, Dimension = Item], Year, TimeStepNumber, Scenario, Year2, TimeStep2, FunctionType, PercentileValue): Get a single result value or an aggregate result value (e.g., sum or average over time). TimeStepNumber is the index of the timestep, where 1 is the first timestep of the water year, e.g., for June, the TimeStepNumber is 6 (assuming the water year begins in January). The Year and TimeStepNumber parameters are omitted for variables that have a single value for the entire study period (e.g., Demand Site Reliability). Omit Year2 and TimeStepNumber2 to get a single value. Available functions for FunctionType are: Total, Average, Median, Minimum, Maximum, Percentile and CV (coefficient of variation). If FunctionType is omitted, the Total will be calculated. PercentileValue is only used if FunctionType is Percentile. If the Scenario parameter is omitted, the active scenario will be used. Will switch to Results View if necessary, calculating results as needed. Read only.

To access MODFLOW cell results, the cell's layer, row and column is given instead of the BranchName: ResultValue(MODFLOWVariableName[layer, row, column], Year, TimeStepNumber, Scenario, Year2, TimeStep2, FunctionType, PercentileValue)

You can specify which scale or unit to report, e.g., Billion Cubic Meters, Acre Feet.  If not specified, the result will be written in the default unit for that unit class:

Unit Class

Default Unit

Area

Square Meter (m^2)

Concentration

Gram/Liter (g/l)

Currency

US Dollar ($)

Energy

Gigajoule (GJ)

Flow

Cubic Meters per Second (CMS)

Length

Meter (m)

Mass

Kilogram (kg)

Power

Kilowatt (kW)

Velocity

Meters/Second (m/s)

Volume

Cubic Meter (m^3)

A few result variables have extra "dimensions," e.g., source, water quality constituent or cost/benefit type.  For these, you can specify the dimension inside the square brackets, after the unit.  If omitted, WEAP will sum up the values across all items, e.g., for costs, it will add Capital Costs, Operating Costs and Benefits.

Note: WEAP.Branch(BranchName).Variables(VariableName).Value(Year, ....) is equivalent to WEAP.ResultValue(BranchName:VariableName, Year, ...), although WEAP.ResultValue lets you choose the scale and unit to report.

PRINT WEAP.ResultValue("\Demand Sites\South City:Reliability") 'Reliability is for the entire study period, so doesn't have a year or time step parameter

PRINT WEAP.ResultValue("\Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Billion Cubic Meter]", 2010, 7)

PRINT WEAP.ResultValue("\Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million]", 2017, 7, "Reference")

PRINT WEAP.ResultValue("\Demand Sites\West City:Unmet Demand[Cubic Feet]", 2015, 1, "Reference", 2015, WEAP.NumTimeSteps) ' total unmet demand for 2015

PRINT WEAP.ResultValue("\Demand Sites\West City:Unmet Demand", WEAP.BaseYear, 1, "Reference", WEAP.EndYear, WEAP.NumTimeSteps) ' total unmet demand for entire study period

PRINT WEAP.ResultValue("\Demand Sites\West City:Unmet Demand", WEAP.BaseYear, 1, "Reference", WEAP.EndYear, WEAP.NumTimeSteps, "Average") ' average unmet demand for entire study period

PRINT WEAP.ResultValue("\Demand Sites\West City:Unmet Demand", WEAP.BaseYear, 1, "Reference", WEAP.EndYear, WEAP.NumTimeSteps, "Percentile", 90) ' the 90th percentile value for unmet demand for entire study period

PRINT WEAP.ResultValue("Cell Head[1, 57, 30]", 2015, 1, "Reference", 2019, 12, "Minimum") ' The minimum groundwater head elevation of cell layer 1, row 57, column 30 in the period 2015-2019 in scenario Reference, as calculated by a linked MODFLOW model.

PRINT WEAP.ResultValue("\Demand Sites\South City:Pollution Generation[kg, WQ Constituent=BOD]", 2010, 7)  ' BOD generated by South City.

PRINT WEAP.ResultValue("\Supply and Resources\River\Weaping River\Returns\Return Flow from South City:Pollution Loads[kg, Source=South City, WQ Constituent=BOD]", 2010, 7)  ' BOD that flows into the Weaping River return flow node from South City.  (There is also inflow from South City WWTP, but it won't be included.)

PRINT WEAP.ResultValue("\Demand Sites\Agriculture West:Supply Delivered[m^3, Source=West Aquifer]", 2010, 7)  ' Supply delivered to Agriculture West from West Aquifer.

PRINT WEAP.ResultValue("\Demand Sites\Agriculture West:Supply Delivered[m^3]", 2010, 7)  ' Supply delivered to Agriculture West from all sources.

PRINT WEAP.ResultValue("\Demand Sites\South City:Net Benefit[$, Cost/Benefit Type=Operating Cost]", 2010, 7)  ' Operating cost at South City.

SaveArea: Save all changes to current area. NOTE: If you close WEAP without calling SaveArea, the changes will not be saved.

WEAP.SaveArea

SaveSchematic(Filename.jpg, Width, ImageQuality): Save schematic to a JPEG (.jpg) graphic file.
SaveSchematic
(Filename.png, Width): Save schematic to a PNG (.png) graphic file.
SaveSchematic
(Filename.kmz, Width, ImageQuality, IsVector, IncludeAreaNotes, IncludeObjectNotes, OpenInGoogleEarth): Save schematic to a Google Earth (kmz) file.  See Export to Google Earth for more information.

Note: The schematic will be saved as it currently appears in the Schematic View.  If you have zoomed in (so that the full area is not visible) or have hidden some WEAP objects (by unchecking them in the upper left legend in the Schematic View), this is what will be saved to the file.  Call WEAP.ZoomSchematic first if you want to zoom out to show the full area boundaries in the saved file.

Filename: The file extension (jpg, png or kmz) determines the type of file saved. 
All parameters after Filename are optional.  If omitted, the default value is used.
Width
: Width (in pixels) of jpg, png or raster Google Earth images.  Range: 50 to 5000.  Default: 800.
ImageQuality
: Range from 5 (low quality) to 100 (high quality).  The higher the quality the larger the file.  Default: 50.
IsVector
: If True, will create a Google Earth file with a clickable object for each WEAP object (e.g., Demand Site, Reservoir, River).  If False, will create a Google Earth file with a single raster image (jpg). Width and ImageQuality are used only if IsVector = False.  IncludeObjectNotes is used only if IsVector = True.  Default: True.
IncludeAreaNotes
: If True, include the area note (as edited in Manage Areas, if any).  Default: True.
IncludeObjectNotes
: If True, include the note for each WEAP object (as edited in Notes View).  In Google Earth, the note will be displayed when the object is clicked.  Object notes can contain html formatting codes.  Default: True.
OpenInGoogleEarth
: If True, open Google Earth and load the file after it is created.  Google Earth is free and can be downloaded from http://earth.google.com  Default: False.

CALL SaveSchematic("C:\Weaping River Basin.jpg")

CALL SaveSchematic("C:\Weaping River Basin.jpg", 1200, 75)

CALL SaveSchematic("C:\Weaping River Basin.png", 2000)

CALL SaveSchematic("C:\Weaping River Basin Vector.kmz")

CALL SaveSchematic("C:\Weaping River Basin Vector.kmz", , , True, False, True, True)

CALL SaveSchematic("C:\Weaping River Basin Raster.kmz", 1200, 85, False, False, , True)

SaveVersion(Comment, IncludeResults): Create a new version of the active area with the given comment. If optional IncludeResults is TRUE, include the results in the version.

WEAP.SaveVersion("Scenario 'Reference' is finished")

WEAP.SaveVersion("Scenario 'Reference' is finished, results included", TRUE)

Scenarios: Get the collection of all scenarios in the active area. See WEAPScenarios for details. Read only.

FOR EACH s IN WEAP.Scenarios
  PRINT WEAP.ResultValue("\Demand Sites\South City:Reliability", , , s.Name)
NEXT

Setting(Key, Section): Set or get a text value associated with a key (text).  Value is stored in file weap.ini in the WEAP main directory.  If Section is not specified, will look in section User.  The weap.ini file can be a convenient place for the user to store settings that apply to all of WEAP.  Area-specific settings can also be saved--see AreaSetting and DeleteAreaSetting.

WEAP.Setting("Custom hydrology model") = "SWAT"

WEAP.Setting("Model directory", "SWAT") = "C:\Program Files\SWAT"

IF WEAP.Setting("Custom hydrology model") = "SWAT" THEN

  ...

END IF

SoftwareVersion: Get the WEAP version number. Read only.

PRINT "WEAP version: "; WEAP.SoftwareVersion

Status: Determine whether the previous property or method call was successful, returning a logical value of TRUE or FALSE. Read only.

IF WEAP.Status = FALSE THEN EXIT FOR

TimeStepName(TimeStepNumber): Get the name of a time step (e.g., "May" or "Oct 15"). Read only.

PRINT WEAP.TimeStepName(12)

Note: This is equivalent to WEAP.Timesteps(12).Name

UserID: Set or get the 3-letter User ID (the user's initials).

WEAP.UserID = "JGS"

UserName: Get the current user's full name.

PRINT WEAP.UserName    

Verbose: Set or get level of information and interaction, from 0-4. 0 = display no messages; 1 = display errors only; 2 = ask questions; 3 = show warnings; 4 = show all messages. The default level is 1.

WEAP.Verbose = 0

WEAP.Verbose = 2

Versions: Get the collection of versions for the active area. See WEAPVersions for details. Read only.

WEAP.Versions("Finished Reference Scenario").Revert

View: Set or get the active view (one of "Schematic", "Data", "Results", "ResultsNoCalculation", "Scenario Explorer" or "Notes").  When switching to the Results or Scenario Explorer views, WEAP will automatically run calculations if necessary.  If set view to ResultsNoCalculation, WEAP will go to the Results View without running calculations.

WEAP.View = "Data"

WEAP.View = "Results"

IF WEAP.View <> "Results" THEN do something

Visible: Show or hide WEAP

WEAP.Visible = TRUE

WEAP.Visible = FALSE

WaterYearStart: Get or set the index for the first timestep of the water year.

PRINT WEAP.WaterYearStart    ' if the water year begins in October, this would be 10

WEAP.WaterYearStart = 3      ' set the water year start to March

Note: WaterYearStart is equivalent to Timesteps(1).CalendarIndex

WorkingDirectory: Gets the full path of the WEAP working directory. Read only.

PRINT WEAP.WorkingDirectory

YearTimeStepName(Year, TimeStepNumber): Get the name of a year and time step (e.g., "May 2010" or "Oct 15 2011"). Read only.

PRINT WEAP.YearTimeStepName(2010, 12)

ZoomSchematic: Zoom out on the Schematic so that it shows the full area boundaries.

WEAP.ZoomSchematic