Example #1
0
def mesh_mixed_shell_and_beams(p: Part):
    p.connections.find()
    with GmshSession(silent=True, options=GmshOptions(Mesh_Algorithm=8)) as gs:
        gmap = dict()
        for obj in p.get_all_physical_objects():
            if type(obj) is Beam:
                li = gs.add_obj(obj,
                                geom_repr="line",
                                build_native_lines=False)
                gmap[obj] = li.entities
            elif type(obj) is Plate:
                pl = gs.add_obj(obj, geom_repr="shell")
                gmap[obj] = pl.entities

        beams = list(p.get_all_physical_objects(by_type=Beam))
        gs.open_gui()
        for pl in p.get_all_physical_objects(by_type=Plate):
            intersecting_beams = []
            for pl_dim, pl_ent in gmap[pl]:
                for bm in find_beams_connected_to_plate(pl, beams):
                    for li_dim, li_ent in gmap[bm]:
                        intersecting_beams.append(li_ent)

            gs.model.mesh.embed(1, intersecting_beams, 2, pl_ent)
            gs.model.geo.synchronize()

        gs.mesh(0.1)
        p.fem = gs.get_fem()
Example #2
0
def generate_meta(part: ada.Part, export_config: ExportConfig):
    meta = dict()
    for obj in part.get_all_physical_objects(
            sub_elements_only=False,
            filter_by_guids=export_config.data_filter.filter_elements_by_guid,
    ):
        meta[obj.guid] = (obj.name, obj.parent.guid)
        if export_config.data_filter.name_filter is not None and len(
                export_config.data_filter.name_filter) > 0:
            if obj.name not in [
                    fi.lower() for fi in export_config.data_filter.name_filter
            ]:
                continue

    for p in part.get_all_parts_in_assembly(True):
        parent_id = p.parent.guid if p.parent is not None else None
        if isinstance(p.parent, ada.Assembly):
            parent_id = "*"
        meta[p.guid] = (p.name, parent_id)

    return meta