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

Revision history [back]

Can you return an OpenStudio runner print from a resource file?

I'm writing a measure that has a resource file that adds some methods to the OpenStudio::Model class.

Let's assume this is the entire content of resources/MyHelper.rb:

 class OpenStudio::Model::Model
      def helloworld()
          puts "Hello World!"
      end
end

In the measure.rb:

require_relative 'resources/MyHelper'
model.helloworld()

How can I modify the MyHelper.rb so that instead of doing a puts statement it basically does a runner.registerInfo("Hello World!")?

Am I forced to pass the runner as an argument to each function of MyHelper.rb that needs to use it?

Also, I've seen the OpenStudio::logFree method, but I'm not sure what its purpose is and how to use it.

Can you return an OpenStudio runner print from a resource file?

I'm writing a measure that has a resource file that adds some methods to the OpenStudio::Model class.

Let's assume this is the entire content of resources/MyHelper.rb:

 class OpenStudio::Model::Model
     def helloworld()
       puts "Hello World!"
     end
end

In the measure.rb:

require_relative 'resources/MyHelper'
model.helloworld()

How can I modify the MyHelper.rb so that instead of doing a puts statement it basically does a runner.registerInfo("Hello World!")?

Am I forced to pass the runner as an argument to each function of MyHelper.rb that needs to use it?

Also, I've seen the OpenStudio::logFree method, but I'm not sure what its purpose is and how to use it.

Can you return an OpenStudio runner print from a resource file?

I'm writing a measure that has a resource file that adds some methods to the OpenStudio::Model class.

Let's assume this is the entire content of resources/MyHelper.rb:

 class OpenStudio::Model::Model
    def helloworld()
      puts "Hello World!"
    end
end

In the measure.rb:

require_relative 'resources/MyHelper'
model.helloworld()
model.helloworld

How can I modify the MyHelper.rb so that instead of doing a puts statement it basically does a runner.registerInfo("Hello World!")?

Am I forced to pass the runner as an argument to each function of MyHelper.rb that needs to use it?

Also, I've seen the OpenStudio::logFree method, but I'm not sure what its purpose is and how to use it.