def line_elem_to_beam(elem: Elem, parent: Part) -> Beam: """Convert FEM line element to Beam""" a = parent.get_assembly() n1 = elem.nodes[0] n2 = elem.nodes[-1] e1 = None e2 = None elem.fem_sec.material.parent = parent if a.convert_options.fem2concepts_include_ecc is True: if elem.eccentricity is not None: ecc = elem.eccentricity if ecc.end1 is not None and ecc.end1.node.id == n1.id: e1 = ecc.end1.ecc_vector if ecc.end2 is not None and ecc.end2.node.id == n2.id: e2 = ecc.end2.ecc_vector if elem.fem_sec.section.type == "GENBEAM": logging.error( f"Beam elem {elem.id} uses a GENBEAM which might not represent an actual cross section" ) return Beam( f"bm{elem.id}", n1, n2, elem.fem_sec.section, elem.fem_sec.material, up=elem.fem_sec.local_z, e1=e1, e2=e2, parent=parent, )
def penetration_check(part: Part): a = part.get_assembly() cog = part.nodes.vol_cog normal = part.placement.zdir for p in a.get_all_subparts(): for pipe in p.pipes: for segment in pipe.segments: if type(segment) is PipeSegStraight: assert isinstance(segment, PipeSegStraight) p1, p2 = segment.p1, segment.p2 v1 = (p1.p - cog) * normal v2 = (p2.p - cog) * normal if np.dot(v1, v2) < 0: part.add_penetration( PrimCyl(f"{p.name}_{pipe.name}_{segment.name}_pen", p1.p, p2.p, pipe.section.r + 0.1))