def constructions_by_id(construction_ids, complete, output_file): """Get several construction definitions from the standards lib at once. \b Args: construction_ids: Any number of construction identifiers to be retrieved from the library. """ try: abridged = not complete cons = [] for con_id in construction_ids: try: cons.append( opaque_construction_by_identifier(con_id).to_dict( abridged=abridged)) except ValueError: try: cons.append( window_construction_by_identifier(con_id).to_dict( abridged=abridged)) except ValueError: cons.append( shade_construction_by_identifier(con_id).to_dict()) output_file.write(json.dumps(cons)) except Exception as e: _logger.exception( 'Retrieval from construction library failed.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def shade_construction_by_id(construction_id, output_file): """Get a shade construction definition from the standards lib with its identifier. \n Args: construction_id: The identifier of a shade construction in the library. """ try: output_file.write(json.dumps(shade_construction_by_identifier( construction_id).to_dict())) except Exception as e: _logger.exception( 'Retrieval from shade construction library failed.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
except ImportError as e: 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 constructions for i, constr in enumerate(_constr): if isinstance(constr, str): _constr[i] = shade_construction_by_identifier(constr) # error message for unrecognized object error_msg = 'Input _hb_objs must be a Room, Face, Aperture, Door, or Shade. Not {}.' # assign the constructions if len(_constr) == 1: for obj in hb_objs: if isinstance(obj, Shade): obj.properties.energy.construction = _constr[0] elif isinstance(obj, (Aperture, Face, Room, Door)): for shd in obj.shades: shd.properties.energy.construction = _constr[0] else: raise TypeError(error_msg.format(type(obj))) else: # assign constructions based on cardinal direction
if len(_name_) != len(_geo) else longest_list(_name_, j) name = clean_and_id_string(display_name) is_detached = not longest_list(attached_, j) if len(attached_) != 0 else True 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