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)
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, )
def extrude_straight_beam(beam, f: "ifile", profile): extrude_dir = ifc_dir(f, (0.0, 0.0, 1.0)) parent = beam.parent.get_ifc_elem() global_placement = create_local_placement( f, relative_to=parent.ObjectPlacement) context = f.by_type("IfcGeometricRepresentationContext")[0] e1 = (0.0, 0.0, 0.0) if Settings.include_ecc and beam.e1 is not None: e1 = beam.e1 profile_e = None if beam.section != beam.taper: profile_e = beam.taper.ifc_profile # Transform coordinates to local coords p1 = tuple([float(x) + float(e1[i]) for i, x in enumerate(beam.n1.p)]) p2 = p1 + np.array([0, 0, 1]) * beam.length p1_ifc = f.create_entity("IfcCartesianPoint", to_real(p1)) p2_ifc = f.create_entity("IfcCartesianPoint", to_real(p2)) ifc_polyline = f.create_entity("IfcPolyLine", [p1_ifc, p2_ifc]) global_origin = f.createIfcCartesianPoint(O) ifc_axis2plac3d = f.create_entity("IfcAxis2Placement3D", global_origin, None, None) if profile_e is not None: extrude_area_solid = f.create_entity("IfcExtrudedAreaSolidTapered", profile, ifc_axis2plac3d, extrude_dir, beam.length, profile_e) else: extrude_area_solid = f.create_entity("IfcExtrudedAreaSolid", profile, ifc_axis2plac3d, extrude_dir, beam.length) # Add colour if beam.colour is not None: add_colour(f, extrude_area_solid, str(beam.colour), beam.colour) ax23d = f.create_entity("IfcAxis2Placement3D", p1_ifc, ifc_dir(f, beam.xvec_e), ifc_dir(f, beam.yvec)) loc_plac = f.create_entity("IfcLocalPlacement", global_placement, ax23d) body = f.create_entity("IfcShapeRepresentation", context, "Body", "SweptSolid", [extrude_area_solid]) axis = f.create_entity("IfcShapeRepresentation", context, "Axis", "Curve3D", [ifc_polyline]) return body, axis, loc_plac
def line_elem_to_ifc(elem: Elem, f, subref, owner_history): """ :param elem: :param f: :param owner_history: :type f: ifcopenshell.file.file :return: """ local_z = f.createIfcDirection(to_real(elem.fem_sec.local_z)) p1 = elem.nodes[0].p p2 = elem.nodes[-1].p edge = f.createIfcEdge(f.createIfcVertexPoint(ifc_p(f, p1)), f.createIfcVertexPoint(ifc_p(f, p2))) edge_topology_rep = f.createIfcTopologyRepresentation(subref["reference"], "Reference", "Edge", (edge,)) edge_prod_def_shape = f.create_entity("IfcProductDefinitionShape", None, None, (edge_topology_rep,)) ifc_stru_member = f.create_entity( "IfcStructuralCurveMember", create_guid(), owner_history, f"E{elem.name}", None, None, create_local_placement(f), edge_prod_def_shape, "RIGID_JOINED_MEMBER", local_z, ) return ifc_stru_member
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))