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

Revision history [back]

Openstudio Python Bindings Set Optionals

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 )
  {
    if(value)
    {
      setDouble(OS_Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,*value);
    }
    else
    {
      setString(OS_Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,"Autosize");
    }
  }

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

coil.setRatedHighSpeedTotalCoolingCapacity(False)

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.

coil.setRatedHighSpeedTotalCoolingCapacity(10000.0)

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

Openstudio Python Bindings Set Optionals

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 )
  {
    if(value)
    {
      setDouble(OS_Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,*value);
    }
    else
    {
      setString(OS_Coil_Cooling_DX_TwoSpeedFields::RatedHighSpeedTotalCoolingCapacity,"Autosize");
    }
  }

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

coil.setRatedHighSpeedTotalCoolingCapacity(False)

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.

coil.setRatedHighSpeedTotalCoolingCapacity(10000.0)

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