Beispiel #1
0
def to_ifc_fem(fem: FEM, f: ifcopenshell.file) -> None:
    owner_history = fem.parent.get_assembly().user.to_ifc()
    f.create_entity(
        "IfcStructuralAnalysisModel",
        create_guid(),
        owner_history,
        fem.name,
        "ADA FEM model",
        ".NOTDEFINED.",
        "LOADING_3D",
    )
    subref = create_reference_subrep(f, create_ifc_placement(f))
    el_ids = []

    logging.warning("Note! IFC FEM export is Work in progress")

    for elem in fem.elements:
        if elem.id not in el_ids:
            el_ids.append(elem.id)
        else:
            logging.error(f'Skipping doubly defined element "{elem.id}"')
            continue

        if elem.shape.elem_type_group == elem.EL_TYPES.LINE:
            _ = line_elem_to_ifc(elem, f, subref, owner_history)
        elif elem.shape.elem_type_group == elem.EL_TYPES.SHELL:
            _ = shell_elem_to_ifc(elem, f, subref, owner_history)
        else:
            logging.error(f'Unsupported elem type "{elem.type}"')
Beispiel #2
0
def export_transform(f: ifcopenshell.file, transform: Transform):
    from ada.core.constants import X

    # https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/annex/annex-e/mapped-shape-with-multiple-items.ifc
    # axis1 = f.create_entity("")
    f.create_entity(
        "IfcCartesianTransformationOperator",
        ifc_dir(f, X),
    )
    raise NotImplementedError()
Beispiel #3
0
def create_ifc_placement(f: ifcopenshell.file, origin=ifco.O, loc_z=ifco.Z, loc_x=ifco.X):
    """
    Creates an IfcAxis2Placement3D from Location, Axis and RefDirection specified as Python tuples

    :param f:
    :param origin:
    :param loc_z:
    :param loc_x:
    :return:
    """

    ifc_loc_z = f.createIfcDirection(to_real(loc_z))
    ifc_loc_x = f.createIfcDirection(to_real(loc_x))
    return f.createIfcAxis2Placement3D(ifc_p(f, origin), ifc_loc_z, ifc_loc_x)
Beispiel #4
0
def create_local_placement(f: ifcopenshell.file, origin=ifco.O, loc_z=ifco.Z, loc_x=ifco.X, relative_to=None):
    """
    Creates an IfcLocalPlacement from Location, Axis and RefDirection,
    specified as Python tuples, and relative placement

    :param f:
    :param origin:
    :param loc_z:
    :param loc_x:
    :param relative_to:
    :return: IFC local placement
    """

    axis2placement = create_ifc_placement(f, origin, loc_z, loc_x)
    ifclocalplacement2 = f.create_entity(
        "IfcLocalPlacement", PlacementRelTo=relative_to, RelativePlacement=axis2placement
    )
    return ifclocalplacement2
Beispiel #5
0
def add_part_objects_to_ifc(p: Part,
                            f: ifcopenshell.file,
                            assembly: Assembly,
                            ifc_include_fem=False):
    # TODO: Consider having all of these operations happen upon import of elements as opposed to one big operation
    #  on export

    part_ifc = p.get_ifc_elem()
    owner_history = assembly.user.to_ifc()
    physical_objects = []
    for m in p.materials.name_map.values():
        f.add(m.ifc_mat)

    for bm in p.beams:
        bm_ifc = write_ifc_beam(bm)
        f.add(bm_ifc)
        physical_objects.append(bm_ifc)

    for pl in p.plates:
        pl_ifc = write_ifc_plate(pl)
        f.add(pl_ifc)
        physical_objects.append(pl_ifc)

    for pi in p.pipes:
        logging.debug(f'Creating IFC Elem for PIPE "{pi.name}"')
        f.add(pi.get_ifc_elem())

    for wall in p.walls:
        wall_ifc = write_ifc_wall(wall)
        f.add(wall_ifc)
        physical_objects.append(wall_ifc)

    for shp in p.shapes:
        if "ifc_file" in shp.metadata.keys():
            ifc_file = shp.metadata["ifc_file"]
            ifc_f = assembly.get_ifc_source_by_name(ifc_file)
            ifc_elem = ifc_f.by_guid(shp.guid)
            new_ifc_elem = f.add(ifc_elem)

            # Simple check to ensure that the new IFC element is properly copied
            # res = get_container(new_ifc_elem)
            # if res is not None:
            #     parent_ifc_elem_guid = str(res.GlobalId, encoding="utf-8")
            #     parent_guid = str(shp.parent.guid, encoding="utf-8")
            #     if parent_ifc_elem_guid != parent_guid:
            #         logging.warning(f"Parent guid and generated ifc guid differs for element {shp.name}")

            physical_objects.append(new_ifc_elem)
        else:
            ifc_shape = write_ifc_shape(shp)
            f.add(ifc_shape)
            physical_objects.append(ifc_shape)

    for instance in p.instances.values():
        write_mapped_instance(instance, f)

    if len(p.fem.nodes) > 0 and ifc_include_fem is True:
        to_ifc_fem(p.fem, f)

    if len(physical_objects) == 0:
        return

    f.create_entity(
        "IfcRelContainedInSpatialStructure",
        create_guid(),
        owner_history,
        "Physical model",
        None,
        physical_objects,
        part_ifc,
    )
Beispiel #6
0
def ifc_p(f: ifcopenshell.file, p):
    return f.create_entity("IfcCartesianPoint", to_real(p))
Beispiel #7
0
def ifc_dir(f: ifcopenshell.file, vec: Tuple[float, float, float]):
    return f.create_entity("IfcDirection", to_real(vec))