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

Revision history [back]

How to add measure to localBCL

How do I add a custom measure to the local BCL and make it accessible via the OpenStudio::LocalBCL methods. Let me explain with an example.

I have defined a local BCL with

path = OpenStudio::Path.new("bcl")
mioBCL = OpenStudio::LocalBCL.instance(path)

I then create a measure with

measure_path = OpenStudio::Path.new("bcl/testmeasure")
measureType = OpenStudio::MeasureType.new(0)
new_measure = OpenStudio::BCLMeasure.new("Test", "TestClass", measure_path, "Envelope.Form", measureType, "Just a measure", "A very Cool Measure")
puts new_measure.uid

I then finally add the measure to the local BCL with

mioBCL.addMeasure(new_measure)

The measure is in the components.sql database, but because the folder created by addMeasure is testmeasure, and not uid/version_id, the measure cannot be found when I use

mioBCL.measures

If I create the folders with the proper names and move the files there everything works as expected. The problem is that I do not know the uid and version_id before creating the measure.

Am I missing something?

How to add measure to localBCL

How do I add a custom measure to the local BCL and make it accessible via the OpenStudio::LocalBCL methods. Let me explain with an example.

I have defined a local BCL with

path = OpenStudio::Path.new("bcl")
mioBCL = OpenStudio::LocalBCL.instance(path)

I then create a measure with

measure_path = OpenStudio::Path.new("bcl/testmeasure")
measureType = OpenStudio::MeasureType.new(0)
new_measure = OpenStudio::BCLMeasure.new("Test", "TestClass", measure_path, "Envelope.Form", measureType, "Just a measure", "A very Cool Measure")
puts new_measure.uid

I then finally add the measure to the local BCL with

mioBCL.addMeasure(new_measure)

The measure is in the components.sql database, but because the folder created by addMeasure is testmeasure, and not uid/version_id, the measure cannot be found when I use

mioBCL.measures

If I create the folders with the proper names and move the files there everything works as expected. The problem is that I do not know the uid and version_id before creating the measure.

Am I missing something?

EDIT:

Just realised that maybe a better approach is to generate the measure from OS Application, use OpenStudio::BCLMeasure.load to create the measure object and then add that object to the database.

How to add measure to localBCL

How do I add a custom measure to the local BCL and make it accessible via the OpenStudio::LocalBCL methods. Let me explain with an example.

I have defined a local BCL with

path = OpenStudio::Path.new("bcl")
mioBCL = OpenStudio::LocalBCL.instance(path)

I then create a measure with

measure_path = OpenStudio::Path.new("bcl/testmeasure")
measureType = OpenStudio::MeasureType.new(0)
new_measure = OpenStudio::BCLMeasure.new("Test", "TestClass", measure_path, "Envelope.Form", measureType, "Just a measure", "A very Cool Measure")
puts new_measure.uid

I then finally add the measure to the local BCL with

mioBCL.addMeasure(new_measure)

The measure is in the components.sql database, but because the folder created by addMeasure is testmeasure, and not uid/version_id, the measure cannot be found when I use

mioBCL.measures

If I create the folders with the proper names and move the files there everything works as expected. The problem is that I do not know the uid and version_id before creating the measure.

Am I missing something?

EDIT:

Just realised that maybe a better approach is to generate the measure from OS Application, use OpenStudio::BCLMeasure.load to create the measure object and then add that object to the database.