Class: Honeybee::Shade
- Inherits:
-
ModelObject
show all
- Defined in:
- lib/honeybee/geometry/shade.rb,
lib/to_openstudio/geometry/shade.rb,
lib/from_openstudio/geometry/shade.rb
Instance Attribute Summary
Attributes inherited from ModelObject
#errors, #openstudio_object, #warnings
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ModelObject
#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Honeybee::ModelObject
Class Method Details
.energy_properties_from_shading_surface(shading_surface) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/from_openstudio/geometry/shade.rb', line 62
def self.energy_properties_from_shading_surface(shading_surface)
hash = {}
hash[:type] = 'ShadeEnergyPropertiesAbridged'
unless shading_surface.isConstructionDefaulted
construction = shading_surface.construction
if !construction.empty?
const_name = clean_name(construction.get.nameString) + ' Shade'
hash[:construction] = const_name
unless $shade_constructions.has_key?(const_name)
const_obj = construction.get
const = const_obj.to_LayeredConstruction.get
$shade_constructions[const_name] = const
end
end
end
transmittance_schedule = shading_surface.transmittanceSchedule
if !transmittance_schedule.empty?
trans_sch_name = clean_name(transmittance_schedule.get.nameString)
unless $schedules[trans_sch_name].nil?
hash[:transmittance_schedule] = trans_sch_name
end
end
hash
end
|
.from_shading_surface(shading_surface, site_transformation) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/from_openstudio/geometry/shade.rb', line 39
def self.from_shading_surface(shading_surface, site_transformation)
hash = {}
hash[:type] = 'Shade'
hash[:identifier] = clean_identifier(shading_surface.nameString)
unless shading_surface.displayName.empty?
hash[:display_name] = (shading_surface.displayName.get).force_encoding("UTF-8")
else
hash[:display_name] = shading_surface.nameString
end
hash[:user_data] = {handle: shading_surface.handle.to_s}
hash[:properties] = properties_from_shading_surface(shading_surface)
hash[:geometry] = geometry_from_shading_surface(shading_surface, site_transformation)
hash
end
|
.geometry_from_shading_surface(shading_surface, site_transformation) ⇒ Object
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/from_openstudio/geometry/shade.rb', line 92
def self.geometry_from_shading_surface(shading_surface, site_transformation)
result = {}
result[:type] = 'Face3D'
result[:boundary] = []
vertices = site_transformation * shading_surface.vertices
vertices.each do |v|
result[:boundary] << [v.x, v.y, v.z]
end
result
end
|
.properties_from_shading_surface(shading_surface) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/from_openstudio/geometry/shade.rb', line 55
def self.properties_from_shading_surface(shading_surface)
hash = {}
hash[:type] = 'ShadePropertiesAbridged'
hash[:energy] = energy_properties_from_shading_surface(shading_surface)
hash
end
|
Instance Method Details
#defaults ⇒ Object
37
38
39
|
# File 'lib/honeybee/geometry/shade.rb', line 37
def defaults
@@schema[:components][:schemas][:ShadeEnergyPropertiesAbridged][:properties]
end
|
#find_existing_openstudio_object(openstudio_model) ⇒ Object
39
40
41
42
43
|
# File 'lib/to_openstudio/geometry/shade.rb', line 39
def find_existing_openstudio_object(openstudio_model)
object = openstudio_model.getSurfaceByName(@hash[:identifier])
return object.get if object.is_initialized
nil
end
|
#to_openstudio(openstudio_model) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/to_openstudio/geometry/shade.rb', line 45
def to_openstudio(openstudio_model)
if @hash[:geometry][:vertices].nil?
hb_verts = @hash[:geometry][:boundary]
else
hb_verts = @hash[:geometry][:vertices]
end
os_vertices = OpenStudio::Point3dVector.new
hb_verts.each do |vertex|
os_vertices << OpenStudio::Point3d.new(vertex[0], vertex[1], vertex[2])
end
os_shading_surface = OpenStudio::Model::ShadingSurface.new(os_vertices, openstudio_model)
os_shading_surface.setName(@hash[:identifier])
unless @hash[:display_name].nil?
os_shading_surface.setDisplayName(@hash[:display_name])
end
if @hash[:properties].key?(:energy)
if @hash[:properties][:energy][:construction]
construction_identifier = @hash[:properties][:energy][:construction]
construction = openstudio_model.getConstructionByName(construction_identifier)
unless construction.empty?
os_construction = construction.get
os_shading_surface.setConstruction(os_construction)
end
end
if @hash[:properties][:energy][:transmittance_schedule]
schedule_identifier = @hash[:properties][:energy][:transmittance_schedule]
schedule = openstudio_model.getScheduleByName(schedule_identifier)
unless schedule.empty?
os_schedule = schedule.get
os_shading_surface.setTransmittanceSchedule(os_schedule)
end
end
if @hash[:properties][:energy][:pv_properties]
gen_obj = PVProperties.new(@hash[:properties][:energy][:pv_properties])
os_gen_obj = gen_obj.to_openstudio(openstudio_model, os_shading_surface)
$generators << os_gen_obj
end
end
os_shading_surface
end
|