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

OpenStudio.BCLMeasure.arguments returns an empty vector

asked 2016-04-28 22:59:05 -0500

updated 2017-08-05 13:29:52 -0500

I'm using C# bindings of OpenStudio API to load measures from file, get it's arguments, modify a number of them and run the measure.

import OpenStudio

measure = OpenStudio.BCLMeasure(OpenStudio.Path(pathToMeasureDir))

args = measure.arguments()

# modify arguments, etc...

The workflow works fine for measures with a standard measure.xml (e.g. radianceMeasure) however when I test it for a measure such as Chilled Beam with DOAS, which misses the arguments tag inside the measure.xml file, it returns an empty BCLComponentVector.

If I load the measure inside OpenStudio App it loads the arguments fine. How does the app loads the arguments? Is there another API call that I should use to get the arguments?

PS: Watch this video for the workaround.

edit retag flag offensive close merge delete

Comments

I think I have an idea why this is happening, I'll follow up when I'm in the office, but if you get a chance can you see if the bar aspect ratio measure works fine. It is under form/opaque.

David Goldwasser's avatar David Goldwasser  ( 2016-04-29 08:17:38 -0500 )edit

Bar aspect ratio also returns no arguments.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 11:08:24 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2016-04-29 10:17:43 -0500

The saga of measure arguments is long and treacherous but I think you are ready :-)

Each measure.xml (should) contain arguments computed in Ruby using an empty seed Model (e.g. Model.new). This happens for all the measures in the My Measures directory when you press the "Sync Project Measures With Library" button in the OpenStudio Application or PAT.

When you actually drag a measure into the OpenStudio Application or PAT, measure arguments are computed with the current model or seed model. This populates drop down menus with correct names of objects in your model and other model dependent stuff. These model dependent arguments are not saved to the measure.xml.

So for your issues, make sure to update the measure.xml file for your measures using the OpenStudio Application. You will not be able to get model dependent arguments from the measure.xml (if that is what you are trying to do). However, this will be a feature in the upcoming OpenStudio Command Line Interface. It might be possible to replicate the argument getting features of the OpenStudio Application but it would require embedded a Ruby interpretter in your C# application (which I doubt is worth the effort).

edit flag offensive delete link more

Comments

1

@Mostapha Roudsari we have many measure on BCL, including "Chilled Beam with DOAS" that were uploaded before the measure class and arguments were written to the XML. We need to update the XML's and then push updates to BCL.

David Goldwasser's avatar David Goldwasser  ( 2016-04-29 10:44:22 -0500 )edit

Thanks @macumber and @david-goldwasser - I will follow Dan's advice and report back. My challenge is that I want everything to happen from Grasshopper interface but I think I can throw a warning to user and tell them to use OpenStudio Application to generate measure.xml before going forward. I assume there is not a clean API call to "Sync Project Measures With Library" without opening the App otherwise that would be out ideal option.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 11:14:14 -0500 )edit

PS: I couldn't figure out how to mention david's name in a comment. :|

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 11:16:29 -0500 )edit

@Mostapha Roudsari, just need to add the space in my name, like your's to mention. Seems like bar aspect ratio needs also to be updated like @macumber mentioned. I have also found some measures that don't update properly even when going through the app, I'll try and investigate why.

David Goldwasser's avatar David Goldwasser  ( 2016-04-29 11:49:21 -0500 )edit

The OpenStudio Command Line Interface will do a lot of what you need, we should give you a demo some time

macumber's avatar macumber  ( 2016-04-29 12:04:07 -0500 )edit

@macumber I failed to generate an updated measure.xml using OpenStudio app and PAT. I made sure that the measures are located under C:\Users\%USERNAME%\OpenStudio\Measures. Once I click on "Sync Project Measures with Library" It shows an empty page. I don't know how to update an image but here is a short screencast.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 12:12:56 -0500 )edit
1

Is that directory the one that you selected in "Preferences->Change My Measures Directory"? If you make a change to the measure.rb file (even just changing whitespace) you should see the measure.xml update.

PS: the update page will show as blank unless any updates are detected.

macumber's avatar macumber  ( 2016-04-29 12:43:38 -0500 )edit

Thanks @macumber! That was it. Problem solved! Just to make sure I'm not missing anything, since you mentioned that OpenStudio CLI will do a lot of what I need I assume that means I can't recreate update measure action by an API call right now. There is an updateMeasureScript method for BCLMeasure but it asks for too many input arguments.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 13:54:22 -0500 )edit

I found an example here. I should be good.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-04-29 14:04:23 -0500 )edit

Hi Mostapha@Mostapha Roudsari , I tried your work-around solution video on youtube and load the same meaure. Now I have a runtime error: {0;0} 0. Runtime error (MissingMemberException): 'SWIGTYPE_p_std__vectorT_BCLMeasureArgument_t' object has no attribute 'Count' 1. Traceback: line 257, in script

Any idea how to solve ?? Thank you

BL's avatar BL  ( 2016-05-02 08:38:47 -0500 )edit

Hi @Bo_Lin. I assumed any vector object in OpenStudio has a count method but your exception shows it's not always the case. Which measure are you trying to load? Can you send me a link to the measure so I can check what is going on.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-05-02 09:24:17 -0500 )edit

That type was not wrapped in OpenStudio until 1.11.1, see this commit. Are you able to update to OpenStudio 1.11.1?

macumber's avatar macumber  ( 2016-05-02 10:47:06 -0500 )edit

Hi @Mostapha Roudsari, the measures are AEDG Office HVAC WSHP with DOAS(https://bcl.nrel.gov/node/39809 ) and AEDG Office HVAC VAV with DX Cooling (https://bcl.nrel.gov/node/39808).

BL's avatar BL  ( 2016-05-02 13:57:10 -0500 )edit

Hi @Bo_Lin, as Dan @macumber mentioned up there you need to update to OpenStudio 1.11.1 or higher to be able to use the honeybee component.

Mostapha Roudsari's avatar Mostapha Roudsari  ( 2016-05-02 21:39:05 -0500 )edit

Your Answer

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

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2016-04-28 22:59:05 -0500

Seen: 279 times

Last updated: Apr 29 '16