Skip to content

Instantly share code, notes, and snippets.

@drheinheimer
Created October 6, 2022 06:22
Show Gist options
  • Save drheinheimer/47ce63791132189c7502c93a80e612d4 to your computer and use it in GitHub Desktop.
Save drheinheimer/47ce63791132189c7502c93a80e612d4 to your computer and use it in GitHub Desktop.
import os
import win32com.client as client # get win32com from Python package pywin32
# See WEAP API at https://www.weap21.org/WebHelp/WEAPApplication.htm
WEAP = client.Dispatch('WEAP.WEAPApplication') # create WEAP object
# Open the area
WEAP.Areas("my area").Open()
# Set the expression
WEAP.Branch("\Demand Sites\my demand site").Variables("Demand").Expression = '5'
# Run the model
WEAP.Calculate()
# Load favorite and save results
WEAP.LoadFavorite("my favorite")
results_path = './my favorite results.csv'
WEAP.ExportResults(results_path, False, False, True) # See docs or experiment with WEAP to understand options
WEAP.Quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment