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

Can you monkey-patch openstudio objects?

asked 2016-01-07 02:59:09 -0600

updated 2018-06-13 08:32:03 -0600

This is more of a theoretical question for my own curiosity, but is it possible to monkey-patch OpenStudio objects, especially to add attributes (tags)?

In some objects such as OS:Space, there are "Measure tags" which are useful in order to selectively apply measure to only some but not all.

For example is it possible to add a tag for some surfaces?

If you just try to add another attribute in a text editor the resulting .osm won't load because it won't pass draft strictness compared to the OpenStudio IDD.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2016-01-07 11:00:35 -0600

updated 2016-01-07 11:00:48 -0600

This is not currently possible, this is one of the reasons we would like to move OpenStudio (and EnergyPlus as well) to a JSON input format. However, those transitions are very difficult and I do not believe they are currently planned for either team.

edit flag offensive delete link more
2

answered 2016-01-07 09:57:54 -0600

updated 2016-01-07 10:04:16 -0600

That's a good question, as you point out we have native support to tag some objects. Space Types can be tagged with the standards building type and standards space type. Constructions have a number of tags including the intended surface type and construction type. One key tag we don't have that I would like eventually is the ability to tag internal loads. I'd like to know if a load is an elevator or a computer without having to rely on the name or infer it using complex logic. Similarly I'd like to know whether a light is task or general lighting, and what kind of technology it uses. Until we have this there are a few options.

  1. Not very pretty one thing we have done is to overload the name with information we want, so for example I could make a lighting definition named "Task|Fluor|Mag|2|30", in one measure. Then in another measure I can parse the name into an array by using name.split("|"). Of course you need to know what each section means. In this case it is "Use Type|Technology|Ballast|Bulbs per fixture|Watts per Bulb".
  2. A variation on this is that every model object in OpenStudio can have a comment. You can set information in the comment instead of the name. Code is shown below. If you don't start the string with an exclamation point and a space, OpenStudio will add that to the beginning of your string.

(code below)

my_object.setComment("anything you want")
puts my_object.comment # this will return "! anything you want"
my_object.setComment("#{my_object.comment}|more info")
puts my_object.comment # this will return "! anything you want|more info"
edit flag offensive delete link more

Comments

Be careful with special characters in your comments (commas, semi-colons, exclamation points, etc), you'll want to do some tests before going whole hog on these approaches

macumber's avatar macumber  ( 2016-01-07 11:02:15 -0600 )edit

Good point @macumber, we have found pipes "|" to be well behaved.

David Goldwasser's avatar David Goldwasser  ( 2016-01-07 11:35:51 -0600 )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: 2016-01-07 02:59:09 -0600

Seen: 172 times

Last updated: Jan 07 '16