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

OpenStudio SDK - using GbXML reverse Translator

asked 2017-09-26 21:50:58 -0500

antonszilasi's avatar

updated 2017-09-27 19:19:12 -0500

I have managed to make an optional model by using the gbxml reverse translator using the code below:

require 'openstudio'

translator = OpenStudio::GbXML::GbXMLReverseTranslator.new

newModel = translator.loadModel(OpenStudio::Path.new('C:\Users\szilasia\Documents\dscEngine\gbxml3.xml'))

Unfortunately the model is not initalized so I can't convert it to a model as seen here

How can I initalize the model?

edit retag flag offensive close merge delete

Comments

@antonszilasi feel free to update the question with your answer from Slack.

MatthewSteen's avatar MatthewSteen  ( 2017-09-28 14:50:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2017-09-27 10:53:37 -0500

You'll have to check if the optional model is initialized and then cast to a Model object with .get, as shown in this answer.

edit flag offensive delete link more

Comments

@Eric Ringold thank you for your answer! Unfortunately the model is not initalized how can I initalize it?

antonszilasi's avatar antonszilasi  ( 2017-09-27 12:44:54 -0500 )edit
1

From Dan's answer:

if (optionalModel.is_initialized()){
  OpenStudio.Model model = optionalModel.get(); // call get only if it is initialized
}

If is_initialized returns false, there is something going wrong in the translation. You could try to print the translator errors and warnings (again, see Dan's answer).

ericringold's avatar ericringold  ( 2017-09-27 12:46:57 -0500 )edit

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2017-09-26 21:50:58 -0500

Seen: 214 times

Last updated: Sep 27 '17