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

Revision history [back]

Why couldn't you? If the SDK has an object, the ruby and the python bindings have it too.

https://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-3.6.1-doc/model/html/classopenstudio_1_1model_1_1_meter_custom.html

Ruby example of API: https://github.com/NREL/OpenStudio-resources/blob/46a3246cd12026af71fc7db11d990697bf002b9b/model/simulationtests/meters.rb#L68-L80

Python works EXACTLY the same, syntax aside.

In [1]: import openstudio

In [2]: m = openstudio.model.exampleModel()

In [3]: meter = openstudio.model.MeterCustom(m)

In [4]: meter.setFuelType("Electricity")
Out[4]: True

In [5]: for l in m.getLightss():
   ...:     meter.addKeyVarGroup(l.nameString(), "Lights Electricity Energy")

In [6]: for e in m.getElectricEquipments():
   ...:     meter.addKeyVarGroup(e.nameString(), "Lights Electricity Energy")

In [7]: print(meter)
OS:Meter:Custom,
  {22211bf0-8e18-4956-9e3c-3038f8e7723e}, !- Handle
  Meter Custom 1,                         !- Name
  Electricity,                            !- Fuel Type
  Lights 1,                               !- Key Name 1
  Lights Electricity Energy,              !- Output Variable or Meter Name 1
  Printer,                                !- Key Name 2
  Lights Electricity Energy,              !- Output Variable or Meter Name 2
  Electric Equipment 1,                   !- Key Name 3
  Lights Electricity Energy;              !- Output Variable or Meter Name 3

Why couldn't you? If the SDK has an object, the ruby and the python bindings have it too.too (very rare exceptions aside)

https://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-3.6.1-doc/model/html/classopenstudio_1_1model_1_1_meter_custom.html

Ruby example of API: https://github.com/NREL/OpenStudio-resources/blob/46a3246cd12026af71fc7db11d990697bf002b9b/model/simulationtests/meters.rb#L68-L80

Python works EXACTLY the same, syntax aside.

In [1]: import openstudio

In [2]: m = openstudio.model.exampleModel()

In [3]: meter = openstudio.model.MeterCustom(m)

In [4]: meter.setFuelType("Electricity")
Out[4]: True

In [5]: for l in m.getLightss():
   ...:     meter.addKeyVarGroup(l.nameString(), "Lights Electricity Energy")

In [6]: for e in m.getElectricEquipments():
   ...:     meter.addKeyVarGroup(e.nameString(), "Lights Electricity Energy")

In [7]: print(meter)
OS:Meter:Custom,
  {22211bf0-8e18-4956-9e3c-3038f8e7723e}, !- Handle
  Meter Custom 1,                         !- Name
  Electricity,                            !- Fuel Type
  Lights 1,                               !- Key Name 1
  Lights Electricity Energy,              !- Output Variable or Meter Name 1
  Printer,                                !- Key Name 2
  Lights Electricity Energy,              !- Output Variable or Meter Name 2
  Electric Equipment 1,                   !- Key Name 3
  Lights Electricity Energy;              !- Output Variable or Meter Name 3

Why couldn't you? If the SDK has an object, the ruby and the python bindings have it too (very rare exceptions aside)

https://s3.amazonaws.com/openstudio-sdk-documentation/cpp/OpenStudio-3.6.1-doc/model/html/classopenstudio_1_1model_1_1_meter_custom.htmlSDK Documentation: MeterCustom Class Reference

Ruby example of API: https://github.com/NREL/OpenStudio-resources/blob/46a3246cd12026af71fc7db11d990697bf002b9b/model/simulationtests/meters.rb#L68-L80OpenStudio-Resources: meters.rb#L68-L88

Python works EXACTLY the same, syntax aside.

In [1]: import openstudio

In [2]: m = openstudio.model.exampleModel()

In [3]: meter = openstudio.model.MeterCustom(m)

In [4]: meter.setFuelType("Electricity")
Out[4]: True

In [5]: for l in m.getLightss():
   ...:     meter.addKeyVarGroup(l.nameString(), "Lights Electricity Energy")

In [6]: for e in m.getElectricEquipments():
   ...:     meter.addKeyVarGroup(e.nameString(), "Lights Electricity Energy")

In [7]: print(meter)
OS:Meter:Custom,
  {22211bf0-8e18-4956-9e3c-3038f8e7723e}, !- Handle
  Meter Custom 1,                         !- Name
  Electricity,                            !- Fuel Type
  Lights 1,                               !- Key Name 1
  Lights Electricity Energy,              !- Output Variable or Meter Name 1
  Printer,                                !- Key Name 2
  Lights Electricity Energy,              !- Output Variable or Meter Name 2
  Electric Equipment 1,                   !- Key Name 3
  Lights Electricity Energy;              !- Output Variable or Meter Name 3