Subject: Re: Access the WEAP API via python. Posted: 8/3/2015 Viewed: 50264 times
I know this is an old topic but better than creating a new one, I believe.
I downloaded the pywin32 package and installed it successfully, but still unable to use WEAP API. By searching through website I didn't get anything. Adding other APIs e.g. MSExcel,MSWord,.. can be done very simply but I have problem adding WEAP API. Any help will be appreciated.
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
Mr. Kasra Keshavarz
Subject: Re: Access the WEAP API via python. Posted: 8/4/2015 Viewed: 50202 times
Well, After 2 days of search and surfing the internet, I finally found that WEAP does not automatically "register" itself.
For registering manually just open Windows "Command Prompt" as Administrator, Go to WEAP install directory (e.g. C:\Program Files\WEAP) and simply run the following command:
After registering, accessing API trough python is never easier than before.
Eng. Miguel Ruiz
Subject: Re: Access the WEAP API via python. Posted: 8/11/2016 Viewed: 45519 times
I want to know if i need close WEAP from python later Calculate and Saving How I can do it?
Ms. Stephanie Galaitsi
Subject: Re: Access the WEAP API via python. Posted: 8/11/2016 Viewed: 45510 times
I'm not sure that I understood your question, but I will direct you to the WEAP Help menu (open up WEAP, and on the ribbon at the top, go to Help/Contents). There, under "Advanced Topics" you will find a detailed section called "Automating WEAP (API)." The subsection "WEAP Application Class" contains several of the commands you may be looking for, including WEAP.Calculate and WEAP.SaveArea.
Mr. Juan Sebastian Ossa Moreno
Subject: Re: Access the WEAP API via python. Posted: 11/24/2017 Viewed: 40409 times
Does anyone know how to adapt lines such as the following (in VBS) into Python?
WEAP.Branch("Supply and Resources\River\Chari\Reaches\Below Return Flow Node28").Variables("Streamflow").Value(my_year,my_month)
I am able to use
WEAP.Branch("Supply and Resources\River\Chari\Reaches\Below Return Flow Node28").Variables("Streamflow").Value
However, when i include brackets after the last word Python thinks i am calling a subset of the object, but as the object is a number it throws an error.