def check_mod(mod, input_name):
    """Get an Modifier from the library if it's a string."""
    if isinstance(mod, str):
        return modifier_by_identifier(mod)
    else:
        assert isinstance(mod, Modifier), \
            'Expected Modifier for {}. Got {}'.format(input_name, type(mod))
    return mod
Exemple #2
0
def modifier_by_id(modifier_id, output_file):
    """Get a modifier definition from the standards lib with its identifier.
    \n
    Args:
        modifier_id: The identifier of a modifier in the library.
    """
    try:
        output_file.write(json.dumps(modifier_by_identifier(modifier_id).to_dict()))
    except Exception as e:
        _logger.exception(
            'Retrieval from modifier library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
Exemple #3
0
def modifiers_by_id(modifier_ids, output_file):
    """Get several modifier definitions from the standards lib at once.
    \n
    Args:
        modifier_ids: A list of modifier identifiers to be retrieved from the library.
    """
    try:
        mods = [modifier_by_identifier(mod_id) for mod_id in modifier_ids]
        output_file.write(json.dumps([mod.to_dict() for mod in mods]))
    except Exception as e:
        _logger.exception(
            'Retrieval from modifier library failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

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


if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    hb_objs = [obj.duplicate() for obj in _hb_objs]

    # process the input modifiers
    for i, mod in enumerate(_mod):
        if isinstance(mod, str):
            _mod[i] = modifier_by_identifier(mod)

    # error message for unrecognized object
    error_msg = 'Input _hb_objs must be a Room, Face, Aperture, Door, or Shade. Not {}.'

    # assign the modifiers
    if len(_mod) == 1:
        for obj in hb_objs:
            if isinstance(obj, Shade):
                obj.properties.radiance.modifier = _mod[0]
            elif isinstance(obj, (Aperture, Face, Room, Door)):
                for shd in obj.shades:
                    shd.properties.radiance.modifier = _mod[0]
            else:
                raise TypeError(error_msg.format(type(obj)))
    else:  # assign modifiers based on cardinal direction
    else:
        vertical_ = [Vector2D(0, 1)]

    # process the input constructions
    if len(ep_constr_) != 0:
        for i, constr in enumerate(ep_constr_):
            if isinstance(constr, str):
                ep_constr_[i] = shade_construction_by_identifier(constr)
    else:
        ep_constr_ = [None]

    # process the input modifiers
    if len(rad_mod_) != 0:
        for i, mod in enumerate(rad_mod_):
            if isinstance(mod, str):
                rad_mod_[i] = modifier_by_identifier(mod)
    else:
        rad_mod_ = [None]

    # gather all of the inputs together
    all_inputs = [
        _depth, _shade_count_, _dist_between_, _facade_offset_, _angle_,
        vertical_, flip_start_, indoor_, ep_constr_, rad_mod_
    ]

    # ensure matching list lengths across all values
    all_inputs, num_orient = check_matching_inputs(all_inputs)

    # get a list of angles used to categorize the faces
    angles = angles_from_num_orient(num_orient)
Exemple #6
0
        _mod: A modifier to be deconstructed or text for a modifier to be looked
            up in the modifier library.

    Returns:
        rad_str: A Radiance string that includes all of the attributes that
            define the modifier.
"""

ghenv.Component.Name = 'HB Deconstruct Modifier'
ghenv.Component.NickName = 'DecnstrMod'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'HB-Radiance'
ghenv.Component.SubCategory = '1 :: Modifiers'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:  # import the honeybee-radiance dependencies
    from honeybee_radiance.lib.modifiers import modifier_by_identifier
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))

try:  # import ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component):
    # check the input
    if isinstance(_mod, str):
        _mod = modifier_by_identifier(_mod)
    rad_str = _mod.to_radiance()
Exemple #7
0
        lb_faces = to_face3d(geo)
        for i, lb_face in enumerate(lb_faces):
            shd_name = '{}_{}'.format(name, i) if len(lb_faces) > 1 else name
            hb_shd = Shade(shd_name, lb_face, is_detached)
            hb_shd.display_name = display_name

            # try to assign the energyplus construction
            if len(ep_constr_) != 0:
                ep_constr = longest_list(ep_constr_, j)
                if isinstance(ep_constr, str):
                    ep_constr = shade_construction_by_identifier(ep_constr)
                hb_shd.properties.energy.construction = ep_constr

            # try to assign the energyplus transmittance schedule
            if len(ep_trans_sch_) != 0:
                ep_trans_sch = longest_list(ep_trans_sch_, j)
                if isinstance(ep_trans_sch, str):
                    ep_trans_sch = schedule_by_identifier(ep_trans_sch)
                hb_shd.properties.energy.transmittance_schedule = ep_trans_sch

            # try to assign the radiance modifier
            if len(rad_mod_) != 0:
                rad_mod = longest_list(rad_mod_, j)
                if isinstance(rad_mod, str):
                    rad_mod = modifier_by_identifier(rad_mod)
                hb_shd.properties.radiance.modifier = rad_mod

            shades.append(hb_shd)  # collect the final Shades
            i += 1  # advance the iterator
    shades = wrap_output(shades)

def is_exterior_wall(face):
    """Check whether a given Face is an exterior Wall."""
    return isinstance(face.boundary_condition, Outdoors) and \
        isinstance(face.type, Wall)


if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    hb_objs = [obj.duplicate() for obj in _hb_objs]

    # process the input modifiers
    for i, constr in enumerate(_mod):
        if isinstance(constr, str):
            _mod[i] = modifier_by_identifier(constr)

    # error message for unrecognized object
    error_msg = 'Input _hb_objs must be a Room, Face, Aperture, or Door. Not {}.'

    # assign the modifiers
    if len(_mod
           ) == 1:  # assign indiscriminately, even if it's a horizontal object
        for obj in hb_objs:
            if isinstance(obj, (Aperture, Door)):
                obj.properties.radiance.modifier = _mod[0]
            elif isinstance(obj, Face):
                for ap in obj.apertures:
                    ap.properties.radiance.modifier = _mod[0]
            elif isinstance(obj, Room):
                for face in obj.faces:
Exemple #9
0
if all_required_inputs(ghenv.Component):
    # duplicate the initial objects
    hb_objs = [obj.duplicate() for obj in _hb_objs]

    # assign default indoor_ property
    indoor_ = indoor_ if indoor_ is not None else False

    # get energyplus constructions if they are requested
    if ep_constr_ is not None:
        if isinstance(ep_constr_, str):
            ep_constr_ = shade_construction_by_identifier(ep_constr_)

    # get radiance modifiers if they are requested
    if rad_mod_ is not None:
        if isinstance(rad_mod_, str):
            rad_mod_ = modifier_by_identifier(rad_mod_)

    # loop through the input objects and add shades
    for obj in hb_objs:
        if isinstance(obj, Room):
            for face in obj.faces:
                for ap in face.apertures:
                    assign_shades(ap, _depth, indoor_, ep_constr_, rad_mod_)
        elif isinstance(obj, Face):
            for ap in obj.apertures:
                assign_shades(ap, _depth, indoor_, ep_constr_, rad_mod_)
        elif isinstance(obj, Aperture):
            assign_shades(obj, _depth, indoor_, ep_constr_, rad_mod_)
        else:
            raise TypeError('Input _hb_objs must be a Room, Face or Aperture. '
                            'Not {}.'.format(type(obj)))