First time here? Check our help page!
2

Errors in converting gbXML to IDF using Ruby Bindings in OpenStudio

I am using Ruby bindings and OpenStudio SDK to convert a gbXML file to IDF. I'm using the code discussed in my previous post that could be found in here. When I am trying to use ForwardTranslator function in IRB it returns an error:

Wrong arguments for overloaded method 'ForwardTranslator.translateModel'.

Attached you can see the screenshot of command prompt. Different commands and outputs are separated in red boxes to make it easier to follow.

I'm not sure what is causing this error shown in the last box. image description

Ehsank's avatar
571
Ehsank
asked 2017-03-19 13:19:23 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2017-04-01 15:29:36 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

2

The error message indicates that translateModel takes an OpenStudio Model object, but what you're passing in is an OptionalModel. Try forward_translator.translateModel(model.get) instead.

OptionalModel is a container that will hold a Model object if the translation succeeded. The get method returns the Model object or fails if the translation failed, so it is a good idea to check to make sure that the optional actually holds something before calling get (if !model ... or similar). Similar issues came up here and here. You're not the first to get tripped up.

Jason DeGraw's avatar
2.2k
Jason DeGraw
answered 2017-03-19 19:40:27 -0500, updated 2017-03-23 09:11:33 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks Jason! You are right. It is working now. I am not sure what exactly ".get" does though. The issue I have at this point is that the changes I make in the source code (e.g., the ReverseTranslator under ...\OpenStudio-2.0.1\openstudiocore\src\gbxml folder) are not reflected in the outputs. For example, I made a change in the warning message but the same message is shown in command line, when I am running my Ruby code. Do you know how could I change the source codes involved in gbXML to IDF conversion? (e.g., OpenStudio.gbXML.ReverseTranslator or OpenStudio.EnergyPlus.ForwardTranslator)

Ehsank's avatar Ehsank (2017-03-22 22:39:45 -0500) edit

I edited my answer to include more about optionals, hope that helps. Are you modifying the C++? if so, you'll need to build OpenStudio and then make sure Ruby is using the "right" OpenStudio (i.e. the one you built instead of the one that is installed). For older versions, see the answers to this question for a couple of different ways to do that. With version 2 and later, it may be different. Maybe @macumber would know.

Jason DeGraw's avatar Jason DeGraw (2017-03-23 09:18:18 -0500) edit
add a comment see more comments