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

Errors in converting gbXML to IDF using Ruby Bindings in OpenStudio

asked 2017-03-19 13:19:23 -0500

Ehsank gravatar image

updated 2017-04-01 15:29:36 -0500

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-19 19:40:27 -0500

updated 2017-03-23 09:11:33 -0500

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.

edit flag offensive delete link more


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 gravatar imageEhsank ( 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 gravatar imageJason DeGraw ( 2017-03-23 09:18:18 -0500 )edit

Your Answer

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

Add Answer


Question Tools



Asked: 2017-03-19 13:19:23 -0500

Seen: 157 times

Last updated: Mar 23