コード例 #1
0
def generate_ifc_cylinder_geom(shape: PrimCyl, f):
    """Create IfcExtrudedAreaSolid from primitive PrimCyl"""
    p1 = shape.p1
    p2 = shape.p2
    r = shape.r

    vec = np.array(p2) - np.array(p1)
    uvec = unit_vector(vec)
    vecdir = to_real(uvec)

    cr_dir = np.array([0, 0, 1])

    if vector_length(abs(uvec) - abs(cr_dir)) == 0.0:
        cr_dir = np.array([1, 0, 0])

    perp_dir = np.cross(uvec, cr_dir)

    if vector_length(perp_dir) == 0.0:
        raise ValueError("Perpendicular dir cannot be zero")

    create_ifc_placement(f, to_real(p1), vecdir, to_real(perp_dir))

    opening_axis_placement = create_ifc_placement(f, to_real(p1), vecdir,
                                                  to_real(perp_dir))

    depth = vector_length(vec)
    profile = f.createIfcCircleProfileDef("AREA", shape.name, None, r)
    return create_ifcextrudedareasolid(f, profile, opening_axis_placement, Z,
                                       depth)
コード例 #2
0
ファイル: write_beams.py プロジェクト: Krande/adapy
def create_polyline_beam(beam, f, profile):
    ifc_polyline = beam.curve.get_ifc_elem()

    extrude_dir = ifc_dir(f, (0.0, 0.0, 1.0))
    global_placement = create_ifc_placement(f)

    extrude_area_solid = f.create_entity("IfcFixedReferenceSweptAreaSolid",
                                         profile, global_placement,
                                         ifc_polyline, 0.0, 1.0, extrude_dir)
    loc_plac = create_ifc_placement(f)
    return extrude_area_solid, loc_plac, ifc_polyline
コード例 #3
0
def shell_elem_to_ifc(elem: Elem, f, subref, owner_history):
    verts = [ifc_vertex(point, f) for point in elem.nodes]

    orientedEdges = []
    for e1, e2 in elem.shape.edges_seq:
        orientedEdges.append(f.createIfcOrientedEdge(None, None, f.createIfcEdge(verts[e1], verts[e2]), True))

    edgeLoop = f.createIfcEdgeLoop(tuple(orientedEdges))
    plane = f.create_entity(
        "IfcPlane", create_ifc_placement(f, to_real(elem.fem_sec.local_z), to_real(elem.fem_sec.local_x))
    )
    faceBound = f.createIfcFaceBound(edgeLoop, True)
    face = f.createIfcFaceSurface((faceBound,), plane, True)
    faceTopologyRep = f.createIfcTopologyRepresentation(subref["reference"], "Reference", "Face", (face,))
    faceProdDefShape = f.createIfcProductDefinitionShape(None, None, (faceTopologyRep,))

    return f.create_entity(
        "IfcStructuralSurfaceMember",
        create_guid(),
        owner_history,
        f"El{elem.name}",
        None,
        None,
        create_local_placement(f),
        faceProdDefShape,
        "SHELL",
        elem.fem_sec.thickness,
    )
コード例 #4
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}"')
コード例 #5
0
def generate_ifc_prim_sweep_geom(shape: PrimSweep, f):
    sweep_curve = shape.sweep_curve.get_ifc_elem()
    profile = f.create_entity("IfcArbitraryClosedProfileDef", "AREA", None,
                              shape.profile_curve_outer.get_ifc_elem())
    ifc_xdir = f.create_entity(
        "IfcDirection", [float(x) for x in shape.profile_curve_outer.xdir])
    opening_axis_placement = create_ifc_placement(f, O, Z, X)

    return create_IfcFixedReferenceSweptAreaSolid(f, sweep_curve, profile,
                                                  opening_axis_placement, None,
                                                  None, ifc_xdir)
コード例 #6
0
def generate_ifc_prim_extrude_geom(shape: PrimExtrude, f):
    """Create IfcExtrudedAreaSolid from primitive PrimExtrude"""
    # https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/link/annex-e.htm
    # polyline = self.create_ifcpolyline(self.file, [p[:3] for p in points])
    normal = shape.poly.normal
    h = shape.extrude_depth
    points = [
        tuple(x.astype(float).tolist()) for x in shape.poly.seg_global_points
    ]
    seg_index = shape.poly.seg_index
    polyline = create_ifcindexpolyline(f, points, seg_index)
    profile = f.createIfcArbitraryClosedProfileDef("AREA", None, polyline)
    opening_axis_placement = create_ifc_placement(f, O, Z, X)
    return create_ifcextrudedareasolid(f, profile, opening_axis_placement,
                                       [float(n) for n in normal], h)
コード例 #7
0
ファイル: write_beams.py プロジェクト: Krande/adapy
def create_ifc_trimmed_curve(curve: CurveRevolve, f: "ifile"):
    loc_plac = create_ifc_placement(f, origin=curve.rot_origin)
    ifc_circle = f.create_entity("IFCCIRCLE", loc_plac, curve.radius)
    param1 = (f.create_entity("IFCPARAMETERVALUE", 0.0), ifc_p(f, curve.p1))
    param2 = (f.create_entity("IFCPARAMETERVALUE",
                              np.deg2rad(curve.angle)), ifc_p(f, curve.p2))
    trim_curve = f.create_entity(
        "IFCTRIMMEDCURVE",
        BasisCurve=ifc_circle,
        Trim1=param1,
        Trim2=param2,
        SenseAgreement=True,
        MasterRepresentation="PARAMETER",
    )
    return trim_curve
コード例 #8
0
def generate_ifc_box_geom(shape: PrimBox, f):
    """Create IfcExtrudedAreaSolid from primitive PrimBox"""
    p1 = shape.p1
    p2 = shape.p2
    points = [
        p1,
        (p1[0], p2[1], p1[2]),
        (p2[0], p2[1], p1[2]),
        (p2[0], p1[1], p1[2]),
    ]
    depth = p2[2] - p1[2]
    polyline = create_ifcpolyline(f, points)
    profile = f.createIfcArbitraryClosedProfileDef("AREA", None, polyline)
    opening_axis_placement = create_ifc_placement(f, O, Z, X)
    return create_ifcextrudedareasolid(f, profile, opening_axis_placement,
                                       (0.0, 0.0, 1.0), depth)
コード例 #9
0
def generate_ifc_prim_revolve_geom(shape: PrimRevolve, f):
    """Create IfcRevolveAreaSolid from primitive PrimRevolve"""
    # https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/link/annex-e.htm
    # 8.8.3.28 IfcRevolvedAreaSolid

    revolve_axis = [float(n) for n in shape.revolve_axis]
    revolve_origin = [float(x) for x in shape.revolve_origin]
    revolve_angle = shape.revolve_angle
    points = [
        tuple(x.astype(float).tolist()) for x in shape.poly.seg_global_points
    ]
    seg_index = shape.poly.seg_index
    polyline = create_ifcindexpolyline(f, points, seg_index)
    profile = f.createIfcArbitraryClosedProfileDef("AREA", None, polyline)
    opening_axis_placement = create_ifc_placement(f, O, Z, X)
    return create_ifcrevolveareasolid(
        f,
        profile,
        opening_axis_placement,
        revolve_origin,
        revolve_axis,
        revolve_angle,
    )
コード例 #10
0
ファイル: write_plates.py プロジェクト: Krande/adapy
def write_ifc_plate(plate: Plate):
    if plate.parent is None:
        raise ValueError(
            "Ifc element cannot be built without any parent element")

    a = plate.parent.get_assembly()
    f = a.ifc_file

    context = f.by_type("IfcGeometricRepresentationContext")[0]
    owner_history = a.user.to_ifc()
    parent = plate.parent.get_ifc_elem()

    xvec = plate.poly.xdir
    zvec = plate.poly.normal
    yvec = np.cross(zvec, xvec)

    # Wall creation: Define the wall shape as a polyline axis and an extruded area solid
    plate_placement = create_local_placement(
        f, relative_to=parent.ObjectPlacement)

    tra_mat = np.array([xvec, yvec, zvec])
    t_vec = [0, 0, plate.t]
    origin = np.array(plate.poly.placement.origin)
    res = origin + np.dot(tra_mat, t_vec)
    polyline = create_ifcpolyline(
        f, [origin.astype(float).tolist(),
            res.tolist()])
    axis_representation = f.createIfcShapeRepresentation(
        context, "Axis", "Curve2D", [polyline])
    extrusion_placement = create_ifc_placement(f, O, Z, X)
    points = [(float(n[0]), float(n[1]), float(n[2]))
              for n in plate.poly.seg_global_points]
    seg_index = plate.poly.seg_index
    polyline = create_ifcindexpolyline(f, points, seg_index)
    # polyline = plate.create_ifcpolyline(f, point_list)
    ifcclosedprofile = f.createIfcArbitraryClosedProfileDef(
        "AREA", None, polyline)

    ifcdir = f.createIfcDirection(zvec.astype(float).tolist())
    ifcextrudedareasolid = f.createIfcExtrudedAreaSolid(
        ifcclosedprofile, extrusion_placement, ifcdir, plate.t)

    body = f.createIfcShapeRepresentation(context, "Body", "SolidModel",
                                          [ifcextrudedareasolid])

    if "hidden" in plate.metadata.keys():
        if plate.metadata["hidden"] is True:
            a.presentation_layers.append(body)

    product_shape = f.createIfcProductDefinitionShape(
        None, None, [axis_representation, body])

    ifc_plate = f.createIfcPlate(
        plate.guid,
        owner_history,
        plate.name,
        plate.name,
        None,
        plate_placement,
        product_shape,
        None,
    )

    plate._ifc_elem = ifc_plate

    # Add colour
    if plate.colour is not None:
        add_colour(f, ifcextrudedareasolid, str(plate.colour), plate.colour)

    # Add penetrations
    # elements = []
    for pen in plate.penetrations:
        # elements.append(pen.ifc_opening)
        f.createIfcRelVoidsElement(
            create_guid(),
            owner_history,
            None,
            None,
            ifc_plate,
            pen.ifc_opening,
        )

    # Material
    f.create_entity(
        "IfcRelAssociatesMaterial",
        create_guid(),
        owner_history,
        plate.material.name,
        plate.name,
        [ifc_plate],
        plate.material.ifc_mat,
    )

    # if "props" in plate.metadata.keys():
    if plate.ifc_options.export_props is True:
        add_multiple_props_to_elem(plate.metadata.get("props", dict()),
                                   ifc_plate, f, owner_history)

    return ifc_plate
コード例 #11
0
def generate_ifc_PrimSphere_geom(shape: PrimSphere, f):
    """Create IfcSphere from primitive PrimSphere"""
    opening_axis_placement = create_ifc_placement(f, to_real(shape.cog), Z, X)
    return f.createIfcSphere(opening_axis_placement, float(shape.radius))
コード例 #12
0
ファイル: write_wall.py プロジェクト: Krande/adapy
def write_ifc_wall(wall: Wall):
    if wall.parent is None:
        raise ValueError(
            "Ifc element cannot be built without any parent element")

    a = wall.parent.get_assembly()
    f = a.ifc_file

    context = f.by_type("IfcGeometricRepresentationContext")[0]
    owner_history = a.user.to_ifc()
    parent = wall.parent.get_ifc_elem()
    elevation = wall.placement.origin[2]

    # Wall creation: Define the wall shape as a polyline axis and an extruded area solid
    wall_placement = create_local_placement(f,
                                            relative_to=parent.ObjectPlacement)

    # polyline = wall.create_ifcpolyline(f, [(0.0, 0.0, 0.0), (5.0, 0.0, 0.0)])
    polyline2d = create_ifcpolyline(f, wall.points)
    axis_representation = f.createIfcShapeRepresentation(
        context, "Axis", "Curve2D", [polyline2d])

    extrusion_placement = create_ifc_placement(f, (0.0, 0.0, float(elevation)),
                                               (0.0, 0.0, 1.0),
                                               (1.0, 0.0, 0.0))

    polyline = create_ifcpolyline(f, wall.extrusion_area)
    profile = f.createIfcArbitraryClosedProfileDef("AREA", None, polyline)

    solid = create_ifcextrudedareasolid(f, profile, extrusion_placement,
                                        (0.0, 0.0, 1.0), wall.height)
    body = f.createIfcShapeRepresentation(context, "Body", "SweptSolid",
                                          [solid])

    if "hidden" in wall.metadata.keys():
        if wall.metadata["hidden"] is True:
            a.presentation_layers.append(body)

    product_shape = f.createIfcProductDefinitionShape(
        None, None, [axis_representation, body])

    wall_el = f.create_entity(
        "IfcWall",
        wall.guid,
        owner_history,
        wall.name,
        "An awesome wall",
        None,
        wall_placement,
        product_shape,
        None,
    )

    # Check for penetrations
    elements = []
    if len(wall.inserts) > 0:
        for i, insert in enumerate(wall.inserts):
            opening_element = add_negative_extrusion(
                f, O, Z, X, insert.height, wall.openings_extrusions[i],
                wall_el)
            if issubclass(type(insert), Part) is False:
                raise ValueError(f'Unrecognized type "{type(insert)}"')
            elements.append(opening_element)
            # for shape_ in insert.shapes:
            #     insert_el = add_ifc_insert_elem(wall, shape_, opening_element, wall_el, insert.metadata["ifc_type"])
            #     elements.append(insert_el)

    f.createIfcRelContainedInSpatialStructure(
        create_guid(),
        owner_history,
        "Wall Elements",
        None,
        [wall_el] + elements,
        parent,
    )

    if wall.ifc_options.export_props is True:
        props = create_property_set("Properties", f, wall.metadata,
                                    owner_history)
        f.createIfcRelDefinesByProperties(
            create_guid(),
            owner_history,
            "Properties",
            None,
            [wall_el],
            props,
        )

    return wall_el