Simple Room Modding Component

This is a solution I found that helps me with my workflow from Revit to LBT.
Getting an analytical model from Revit to LBT can be problematic to say the least. With detailed models including non-orthogonal geometry the analytical model from Revit has loads of problems so I’ve found it’s more reliable to export the gbXML from Rooms and then do all the tinkering in LBT, which can be streamlined.

Anyway, importing the gbXML produces rooms sort-of-ready for simulation as these are non-conditioned, have no program, etc. Instead of rebuilding the rooms I’ve done minor modifications the “HB Room” component to allow me to quickly set construction set, program, is_conditioned.

Maybe some of you will find it helpful.

In inputs:
replace _faces for _rooms
get rid of _names

outputs:
out and rooms

Code Next:

ghenv.Component.Name = "HB Room Modder"
ghenv.Component.NickName = 'Room Modder'
ghenv.Component.AdditionalHelpFromDocStrings = "2"


try:  # import the core honeybee dependencies
    from honeybee.room import Room
    from honeybee.typing import clean_and_id_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:  # import the ladybug_rhino dependencies
    from ladybug_rhino.config import tolerance, angle_tolerance
    from ladybug_rhino.grasshopper import all_required_inputs, give_warning, \
        document_counter
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

try:  # import the honeybee-energy extension
    from honeybee_energy.lib.programtypes import program_type_by_identifier, office_program
    from honeybee_energy.lib.constructionsets import construction_set_by_identifier
except ImportError as e:
    if _program_ is not None:
        raise ValueError('_program_ has been specified but honeybee-energy '
                         'has failed to import.\n{}'.format(e))
    elif _constr_set_ is not None:
        raise ValueError('_constr_set_ has been specified but honeybee-energy '
                         'has failed to import.\n{}'.format(e))
    elif conditioned_ is not None:
        raise ValueError('conditioned_ has been specified but honeybee-energy '
                         'has failed to import.\n{}'.format(e))

try:  # import the honeybee-radiance extension
    from honeybee_radiance.lib.modifiersets import modifier_set_by_identifier
except ImportError as e:
    if _mod_set_ is not None:
        raise ValueError('_mod_set_ has been specified but honeybee-radiance '
                         'has failed to import.\n{}'.format(e))


if all_required_inputs(ghenv.Component):
    
    for room in _rooms:
        # check that the Room geometry is closed.
        if not room.check_solid(tolerance, angle_tolerance, False):
            give_warning(ghenv.Component, 'Input _rooms do not form a closed volume.\n'
                         'Room volume must be closed to access most honeybee features.\n'
                         'Preview the output Room to see the holes in your model.')
    
        # try to assign the modifier set
        if _mod_set_ is not None:
            if isinstance(_mod_set_, str):
                _mod_set_ = modifier_set_by_identifier(_mod_set_)
            room.properties.radiance.modifier_set = _mod_set_
    
        # try to assign the construction set
        if _constr_set_ is not None:
            if isinstance(_constr_set_, str):
                _constr_set_ = construction_set_by_identifier(_constr_set_)
            room.properties.energy.construction_set = _constr_set_
    
        # try to assign the program
        if _program_ is not None:
            if isinstance(_program_, str):
                _program_ = program_type_by_identifier(_program_)
            room.properties.energy.program_type = _program_
        else:  # generic office program by default
            try:
                room.properties.energy.program_type = office_program
            except (NameError, AttributeError):
                pass  # honeybee-energy is not installed
    
        # try to assign an ideal air system
        if conditioned_ or conditioned_ is None:  # conditioned by default
            try:
                room.properties.energy.add_default_ideal_air()
            except (NameError, AttributeError):
                pass  # honeybee-energy is not installed
                
    rooms = _rooms