1

Remove Os:AirTerminal

I have modified the user script to remove unused thermal zones (they remain after deleting the space). Before deleting the thermal zone, I delete the zone equipment. It works fine with everything except with AirTerminal type equipment. If there is an AirTerminal in the zone equipment, Sketchup or Openstudio will crash after removing. This is the code:

def removeUnusedThermalZones(model)
  thermal_zones = model.getThermalZones

  thermal_zone_handles_to_remove = OpenStudio::UUIDVector.new
  equipmentListToRemove = []

  thermal_zones.each do |thermal_zone|
    if thermal_zone.spaces.empty?  && thermal_zone.isRemovable
      thermal_zone_handles_to_remove << thermal_zone.handle
      if not thermal_zone.equipment.empty?
        thermal_zone.equipment.each do |equip| 
          equipmentListToRemove<< equip
        end
      end
    end
  end

  if not equipmentListToRemove.empty?
    equipmentListToRemove.each {|equip|
      equip.remove
    }
  end

  if not thermal_zone_handles_to_remove.empty?
    model.removeObjects(thermal_zone_handles_to_remove)
  else
    puts "No unused thermal zones to remove."
  end
end
mapascual's avatar
653
mapascual
asked 2017-08-05 02:01:49 -0500, updated 2017-08-08 01:43:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

You can use the removeBranchForZone method in the AirLoopHVAC object to delete the AirTerminal object.

Code will look something like:

model.getAirLoopHVACs.each do |loop|
  loop.removeBranchForZone(thermal_zone)
end

or better:

model.getThermalZones.each do |zone|
  if !zone.airLoopHVACTerminal.empty?
    terminal = zone.airLoopHVACTerminal.get
    if !terminal.airLoopHVAC.empty?
      air_loop = terminal.airLoopHVAC.get
      air_loop.removeBranchForZone(zone)
    end
  end
end
mdahlhausen's avatar
9.5k
mdahlhausen
answered 2017-08-07 16:45:11 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks for your answer. I tried the first approach and it seems to work.

mapascual's avatar mapascual (2017-08-08 01:40:39 -0500) edit
add a comment see more comments