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

Cannot find OpenStudio::Model::ShadingSurfaceGroup(model) in OS Ruby API

asked 2017-02-17 19:23:28 -0600

updated 2017-08-21 08:42:25 -0600

Do anyone use the OpenStudio::Model::ShadingSurfaceGroup(model) in Ruby API?

I got the error as follows: :in create_os_object': undefined methodShadingSurfaceGroup' for OpenStudio:Module (NoMethodError)

I tested it on both OS Version: 1.14.0 and 1.12.0.

Any suggestions?

Also, do we have to associated the ShadingSurface with ShadingSurfaceGroup always?

The OS:ShadingSurface was in the osm. But don't transfer to any shading object in E+.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2017-02-18 14:03:06 -0600

updated 2017-02-19 13:42:22 -0600

I'm able to create a ShadingSurfaceGroup using the 1.14.0 API. It looks like you're forgetting the .new method which takes a model object as the argument.

# OpenStudio Ruby Bindings
require 'openstudio'

# create model
model = OpenStudio::Model::Model.new

# create shading surface group
ssg = OpenStudio::Model::ShadingSurfaceGroup.new(model)

# print to screen
puts model

.

OS:Version,
  {14d449ea-4980-4b2b-9a87-ed83cacecc47}, !- Handle
  1.14.0;                                 !- Version Identifier

OS:ShadingSurfaceGroup,
  {6f4c00a8-2aea-44d5-9752-daa71fa82220}, !- Handle
  Shading Surface Group 1,                !- Name
  Building;                               !- Shading Surface Type

DL is deprecated, please use Fiddle

If you create a ShadingSurface in the OpenStudio SketchUp Plugin using the New Shading Surface Group button it will also add a ShadingSurfaceGroup to the model. The ShadingSurface is translated to an EnergyPlus Shading:Building:Detailed object.

# OpenStudio Ruby Bindings
require 'openstudio'

# directory
dir = 'C:\Users\Matt\Documents\TOOLBOX\OpenStudio'

# files and paths
osm = 'OSplugin_1.14.0_shading'
osm_path = File.join(dir, osm + '.osm')

# get model
model = OpenStudio::Model::Model.load(osm_path).get

# print to screen
puts "\n", 'OPENSTUDIO OBJECTS'
puts model.getShadingSurfaceGroups
puts model.getShadingSurfaces

# forward translate to IDF
forward_translator = OpenStudio::EnergyPlus::ForwardTranslator.new
idf = forward_translator.translateModel(model)

# save IDF
idf_path = File.join("#{__FILE__}/ShadingSurfaceGroup.idf")
idf.save(idf_path, true)

# get workspace and shading surface
workspace = OpenStudio::Workspace.load(idf_path).get
ep_ss = workspace.getObjectByTypeAndName('Shading_Building_Detailed'.to_IddObjectType, 'Shading Surface 1').get

# print to screen
puts "\n", 'ENERGYPLUS OBJECTS'
puts ep_ss

.

OPENSTUDIO OBJECTS

OS:ShadingSurfaceGroup,
  {fd7b1c49-c4cd-4507-95d4-eba000509200}, !- Handle
  Shading Surface Group 1,                !- Name
  Building,                               !- Shading Surface Type
  ,                                       !- Space Name
  ,                                       !- Direction of Relative North {deg}
  0,                                      !- X Origin {m}
  0,                                      !- Y Origin {m}
  3.048,                                  !- Z Origin {m}
  ;                                       !- Shaded Object Name

OS:ShadingSurface,
  {cec21c5d-182c-462d-ad9e-deb697a9d0a0}, !- Handle
  Shading Surface 1,                      !- Name
  ,                                       !- Construction Name
  {fd7b1c49-c4cd-4507-95d4-eba000509200}, !- Shading Surface Group Name
  ,                                       !- Transmittance Schedule Name
  ,                                       !- Number of Vertices
  3.048, -1.08807845866769, 0,            !- X,Y,Z Vertex 1 {m}
  3.048, 0, 0,                            !- X,Y,Z Vertex 2 {m}
  0, 0, 0,                                !- X,Y,Z Vertex 3 {m}
  0, -1.08807845866769, 0;                !- X,Y,Z Vertex 4 {m}


ENERGYPLUS OBJECTS

Shading:Building:Detailed,
  Shading Surface 1,                      !- Name
  ,                                       !- Transmittance Schedule Name
  ,                                       !- Number of Vertices
  3.048, -1.08807845866769, 3.048,        !- X,Y,Z Vertex 1 {m}
  3.048, 0, 3.048,                        !- X,Y,Z Vertex 2 {m}
  0, 0, 3.048,                            !- X,Y,Z Vertex 3 {m}
  0, -1.08807845866769, 3.048;            !- X,Y,Z Vertex 4 {m}
edit flag offensive delete link more

Comments

Nice. I forgot the .new.

Thank you.

Yixing Chen's avatar Yixing Chen  ( 2017-02-18 17:47:50 -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: 2017-02-17 19:23:28 -0600

Seen: 240 times

Last updated: Feb 19 '17