Hello, Could some one can tell me how can I assign the building unit to the spaces using ruby scripts. I tried to do something as follows, but it doesn't work
unit = OpenStudio::Model::BuildingUnit.new(model)
unit.setBuildingUnitType("Residential")
spaces.each do |space|
space_name = [] # space name as a list
if space.name.to_s.include? '_'
space_name = space.name.to_s.split('_') # split space name
else
space_name[0] = space.name.to_s
end
if ["A","B","C","D","M"].any? {|prefix| space_name[0].include? prefix}
if space.buildingUnit.empty? || !space.buildingUnit.get.name.to_s.include?(space_name[0])
unit.setName(space_name[0])
space.setBuildingUnit(unit)
end
end
end
I am a very newbie in using OpenStudio and Openstudio SDK.
Thanks
Long