6

AdditionalProperties

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?

mapascual's avatar
653
mapascual
asked 2018-06-22 11:38:24 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2018-06-23 10:43:25 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

6

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"
shorowit's avatar
11.8k
shorowit
answered 2018-06-22 14:43:58 -0500, updated 2018-06-22 15:34:57 -0500
edit flag offensive 0 remove flag delete link

Comments

It works. Thank you!

mapascual's avatar mapascual (2018-06-23 01:32:13 -0500) edit

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 (2020-08-17 21:31:58 -0500) edit

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 (2020-08-17 21:35:11 -0500) edit

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 (2020-08-20 03:09:10 -0500) edit

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 (2020-08-20 03:12:21 -0500) edit
add a comment see more comments