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

Insert Component from BCL with Ruby API

asked 9 years ago

pflaumingo's avatar

updated 7 years ago

What's the best way to insert a component from a BCL (local or remote) into a model? For example, if I wanted to grab one of the LG heatpump BCL components and place it into my model. Would you first create an object of the same type and set it's properties from the BCL class? Or is there an easy way to instantiate an object straight from the BCL?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 9 years ago

updated 9 years ago

Good question, I have a few sample measures to do this with both a construction and a weather file (actually site component with a few object types). They are not ready to go on BCL, but here is a link to the construction example on a public repo which is probably the better example for you of the two (keep in mind they are not on BCL because they are not flushed out and tested, but they should still be a useful guide to follow). You want to bring in the real BCL object vs. creating a new object and copying the attributes. The measure first hits BCL in the arguments section to populate a choice list. Then hits it again in the run section to download and apply the selected component.

The trick is coming up with logic to have a choice list that works but doesn't have too many items in it. In the construction example linked above I assume the model has a climate zone set (in the site tab); that narrows down the choices to constructions tagged for that climate zone. I also wrote it only for exterior walls to further narrow it down. The SketchUp plugin user script that hits BCL and gets a weather file can first ask you to type the name of a city and then bring up a choice list of 4-5 options. With measures you don't have interactive arguments in that the selection made on the first argument can't change what choices are shown for the next one. You might be ok for now for Technology Performance Exchange Objects. If you had an argument for Indoor Unit, and another for Outdoor, they would have 79 and 52 choices respectively. Long but still manageable.

Preview: (hide)
link

Comments

@David Goldwasser, thanks!. The link definitely cleaned a few things up. I am doing something rather similar, but I was also curious if there was a convenient method that was something like componentData = model.insertComponentFromBCL(uid) that I may have been missing or not seen. Moving slightly off topic, when you pull an outdoor component from the BCL and instantiate an object will it always create all objects in the associated .osc? If I had multiple outdoor units with the same performance curves, is there a simple way to just create one OS:Table:MultiVariableLookup object?

pflaumingo's avatar pflaumingo  ( 9 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: 9 years ago

Seen: 415 times

Last updated: May 27 '15