Subject: Error in reading variable's value via Python Posted: 2/1/2018 Viewed: 5737 times
Hi,
When I run the following code in JScript, I see the result
JScript Code:
var WEAP = new ActiveXObject("WEAP.WEAPApplication");
WEAP.ActiveArea = "Tutorial";
var V = WEAP.Branch("\\Demand Sites\\City").Variables("Annual Activity Level");
var Temp = V.Value(2011, 1, "No LEAP Link");
print("Done. Value = " + Temp);
But when I run the equivalent code in python (following code) I get an error
Python Code:
import win32com.client
WEAP = win32com.client.Dispatch('WEAP.WEAPApplication')
v = WEAP.Branch('\\Demand Sites\\demand').Variables('Monthly Variation').Value(2015, 1)
print('Done. {}'.format(v))
Error: TypeError: 'float' object is not callable
Note) If I use Value without any parameter (like a property), it works but just return the first value (for example when I use MonthlyValues for its Expression {I mean using WEAP.Branch('\\Demand Sites\\demand').Variables('Monthly Variation').Value}
What should I do to read values of a variable (for individual timesteps) in Python?!?
Dr. Yilin Chen
Subject: Re: Error in reading variable's value via Python Posted: 5/19/2022 Viewed: 7 times
Hi,
Have you solved this problem? I used the function named "ResultValue" instead.
v = WEAP.Branch('\\Demand Sites\\demand').Variables('Monthly Variation').ResultValue(2015, 1)
Do you have any advanced methods to read a large portion of data?
Topic "Error in reading variable's value via Python"