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

AdditionalProperties

asked 6 years ago

updated 6 years ago

I have noticed that OpenStudio 2.5 includes a new class: OpenStudio::Model::AdditionalProperties

I am trying to write some userscripts and measures and it would be very helpful to use this objet. The problem is I dont know how to create this object and how to assign it to the openstudio models.

Can anybody provide a simple use example?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
6

answered 6 years ago

updated 6 years ago

Every OpenStudio model object now has an AdditionalProperties object available on it to store meta information. If you ask for the object and it doesn't already exist, it is automatically created for you. Once you have the object, see the OpenStudio SDK documentation for all of the available methods.

For example:

mat = OpenStudio::Model::StandardOpaqueMaterial.new(model)
props = mat.additionalProperties
props.setFeature("color", "white")
puts props.getFeatureAsString("color") # => "white"
Preview: (hide)
link

Comments

It works. Thank you!

mapascual's avatar mapascual  ( 6 years ago )

There is no way to get the AddditionalProperties associated with the OutputVariable . I added additionalproperties to each output variable in the openstudio core code ... but in the application code i am not able to retrieve them .... How can i retrieve the AddditionalProperties associated with each output variable ?

riteshsahoo's avatar riteshsahoo  ( 4 years ago )

There is no way to get the std::vector<outputvariable> outputVariables() for the object ... must run simulation to generate data. why do we need to run ? How can i get the list of all the output variable ...not names ?

riteshsahoo's avatar riteshsahoo  ( 4 years ago )

You're asking several questions as one in a comment thread, which is bad practice as it makes it hard to respond.

Here's an example using the ruby bindings and demonstrating that it works with OutputVariable.

 include OpenStudio::Model
 m = Model.new
 o = OutputVariable.new("Coucou", m)
 o.additionalProperties.setFeature("color", "blue")
 => true
 o.additionalProperties.getFeatureAsString("color").get
 => "blue"
Julien Marrec's avatar Julien Marrec  ( 4 years ago )

And if you need to list all output variables, this is, as with all other ModelObjects something you would retrieve from Model. In ruby that's m.getOutputVariables(), in C++ m.getConcreteModelObjects<OutputVariable>()(there's also a getModelObjects<T>() for non concrete ones).

Source: Model.hpp#L280-L315

Julien Marrec's avatar Julien Marrec  ( 4 years ago )

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: 6 years ago

Seen: 373 times

Last updated: Jun 22 '18