Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Openstudio Python Bindings Set Optionals

asked 2015-07-01 13:49:39 -0500

updated 2015-07-11 13:39:24 -0500

I'm trying to set an optional double in the CoilCoolingDXTwoSpeed class. The SDK documentation mentions that the parameter will be set to autosize if the value is false or a value is specified if provided.

The C++ code for this component is:

  // N1 , \field Rated High Speed Total Cooling Capacity

 OptionalDouble CoilCoolingDXTwoSpeed_Impl::ratedHighSpeedTotalCoolingCapacity() const
    return getDouble(OS_Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity);

  void CoilCoolingDXTwoSpeed_Impl::setRatedHighSpeedTotalCoolingCapacity( OptionalDouble value )

I'm struggling with the appropriate syntax in the Python bindings to make this work. The command:


gives the following error:

TypeError: in method 'CoilCoolingDXTwoSpeed_setRatedHighSpeedTotalCoolingCapacity', argument 2 of type 'boost::optional< double

I actually get the same error if a double value is provided.


Is there a specific syntax required to provide the value as an optional double?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-07-01 13:54:04 -0500

updated 2016-10-14 12:41:54 -0500

I'm not sure of the exact syntax but you may need to do something like:

value =

Just as an FYI, that argument signature is against our normal patterns. We might change it to conform (e.g. just take a double as input) at some point.


edit flag offensive delete link more


@macumber that is the Ruby version, right? In Python the syntax becomes:

value = openstudio.OptionalDouble(10000.0)

also to set the "autosize" flag you can use

value = openstudio.OptionalDouble()
jmcneill's avatar jmcneill  ( 2015-07-01 14:10:38 -0500 )edit

Yeah we didn't have all of these conventions worked out in the early days. It should be setRatedHighSpeedTotalCoolingCapacity(double) and resetRatedHighSpeedTotalCoolingCapacity (). Furthermore I am trying to avoid optional fields altogether unless the mere presence of a field alters how E+ behaves.

Kyle Benne's avatar Kyle Benne  ( 2015-07-01 14:25:05 -0500 )edit

@Kyle Benne will the older components like the CoilCoolingDXTwoSpeed be updated in future versions? I'm still using 1.6.0.

jmcneill's avatar jmcneill  ( 2015-07-01 14:28:56 -0500 )edit

I'm thinking we should overload the setMethods with the setter that takes the non optional value, leaving but depreciating the old method so not to break our client code and Measures. But I admit this hasn't become a priority yet considering we are still trying to crank in new features.

Kyle Benne's avatar Kyle Benne  ( 2015-07-01 14:48:50 -0500 )edit

1.8.0 will look just like 1.6.0 for these objects. I expect we may take a double in future versions but I think we would still also accept an optional double so that previously written measures will work. FYI - colingColingDXSingleSpeed.setRatedCOP also takes an optional double, however the low and high speed COP values on the two speed object do not take an optional double.

David Goldwasser's avatar David Goldwasser  ( 2015-07-01 14:51:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops


Question Tools

1 follower


Asked: 2015-07-01 13:49:39 -0500

Seen: 353 times

Last updated: Oct 14 '16