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

Setting an attribute that isn't exposed in the OpenStudio API?

asked 9 years ago

updated 7 years ago

For example, I want to set the Setpoint of an OS:ShadingControl. The documentation for this object is here. As can be seen, there's no direct access to the setpoint.

How can I set it?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 9 years ago

updated 9 years ago

Here is an example of what NOT to do.

Indeed, Openstudio will just ignore that value and replace it with 100.


Let's say you have stored your ShadingControl in the variable shading_ctrl

In [1]: puts shading_ctrl.to_s
Out[1]:
OS:ShadingControl,
  {a3e408c3-3dd3-4ea9-9c3f-b0af445a2c9d}, !- Handle
  Shading Control 1,                      !- Name
  SwitchableGlazing,                      !- Shading Type
  {f47a3380-fc6c-4fee-b208-3e45ebf9cd82}, !- Construction with Shading Name
  ,                                       !- Shading Device Material Name
  ,                                       !- Shading Control Type
  ,                                       !- Schedule Name
  ,                                       !- Setpoint {BasedOnField A4}
  ,                                       !- Shading Control Is Scheduled
  ,                                       !- Glare Control Is Active
  ,                                       !- Type of Slat Angle Control for Blinds
  ,                                       !- Slat Angle Schedule Name
  ;                                       !- Setpoint 2 {BasedOnField A4}

As can be seen above, setpoint has index 7 (it's 0-indexed, so Handle is 0, Name is 1...)

You can then use the setDouble method which accepts an index, and a double. Let's say I want to set setpoint to 25 W/m².

In[2]:  shading_ctrl.setAttribute(7, 20)
Out[2]: => true

In[3]: # Let's verify
puts shading_ctrl.to_s
Out[3]:
OS:ShadingControl,
  {a3e408c3-3dd3-4ea9-9c3f-b0af445a2c9d}, !- Handle
  Shading Control 1,                      !- Name
  SwitchableGlazing,                      !- Shading Type
  {f47a3380-fc6c-4fee-b208-3e45ebf9cd82}, !- Construction with Shading Name
  ,                                       !- Shading Device Material Name
  ,                                       !- Shading Control Type
  ,                                       !- Schedule Name
  20,                                       !- Setpoint {BasedOnField A4}
  ,                                       !- Shading Control Is Scheduled
  ,                                       !- Glare Control Is Active
  ,                                       !- Type of Slat Angle Control for Blinds
  ,                                       !- Slat Angle Schedule Name
  ;                                       !- Setpoint 2 {BasedOnField A4}
Preview: (hide)
link

Comments

Except OpenStudio will remove it and use its default value. Bummer

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

Might still work, depending on the Shading Control Type. See here

ericringold's avatar ericringold  ( 9 years ago )

That field was intentionally not added to the API, however it is in the data model for future use. This really is an odd object where we are trying to balance between what you can do in EnergyPlus and in Radiance.

macumber's avatar macumber  ( 9 years ago )

@Julien Marrec does this mean you got IRuby working?

MatthewSteen's avatar MatthewSteen  ( 9 years ago )

@Eric Ringold: I've checked the out.idf, it does strip out the value I've used and replaces it with 100, even though I'm using OnIfHighSolarOnWindow... I guess I'll have to use an EnergyPlus measure... @MatthewSteen: Nope, I'm just used to formatting code this way on Stack Overflow. I did try really hard to install iruby. I think I've just managed to induce some momentum to fix it (here, the creator of the failing rbcmz says he'll look into it)

Julien Marrec's avatar Julien Marrec  ( 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: 393 times

Last updated: Sep 08 '15