def add_fem(ifc_file, part): """ :param ifc_file: :param part: :type part: ada.Part :return: """ from itertools import groupby from operator import attrgetter from ada.fem import ElemShapes ifc_file.createIfcStructuralAnalysisModel( create_guid(), ifc_file.by_type("IfcOwnerHistory")[0], "Structural Analysis", "Example analysis", ".NOTDEFINED.", "LOADING_3D", ) fem = part.fem for el_type, elements in groupby(fem.elements, key=attrgetter("type")): if el_type in ElemShapes.beam: for elem in elements: # TODO: add_fem_elem_beam(elem, parent) pass
def to_ifc_fem(fem, f): """ :param fem: :param f: :type fem: ada.fem.FEM :type f: ifcopenshell.file.file :return: """ from ada.core.ifc_utils import create_global_axes, create_reference_subrep owner_history = f.by_type("IfcOwnerHistory")[0] f.create_entity( "IfcStructuralAnalysisModel", create_guid(), owner_history, fem.name, "ADA FEM model", ".NOTDEFINED.", "LOADING_3D", ) subref = create_reference_subrep(f, create_global_axes(f)) for el_type, elements in groupby(fem.elements, key=attrgetter("type")): if el_type in ElemShapes.beam: for elem in elements: elem_to_ifc(elem, f, subref) logging.error("Note! IFC FEM export is Work in progress")
def elem_to_ifc(elem, f, subref): """ :param elem: :param f: :type elem: ada.fem.Elem :type f: ifcopenshell.file.file :return: """ from ada.core.ifc_utils import create_local_placement, ifc_p, to_real 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.createIfcProductDefinitionShape(None, None, (edge_topology_rep,)) owner_history = f.by_type("IfcOwnerHistory")[0] 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 add_negative_extrusion(f, origin, loc_z, loc_x, depth, points, parent): """ :param f: :param origin: :param loc_z: :param loc_x: :param depth: :param points: :param parent: :return: """ context = f.by_type("IfcGeometricRepresentationContext")[0] owner_history = f.by_type("IfcOwnerHistory")[0] # Create and associate an opening for the window in the wall opening_placement = create_ifclocalplacement(f, origin, loc_z, loc_x, parent.ObjectPlacement) opening_axis_placement = create_ifcaxis2placement(f, origin, loc_z, loc_x) polyline = create_ifcpolyline(f, points) ifcclosedprofile = f.createIfcArbitraryClosedProfileDef("AREA", None, polyline) opening_solid = create_ifcextrudedareasolid(f, ifcclosedprofile, opening_axis_placement, loc_z, depth) opening_representation = f.createIfcShapeRepresentation(context, "Body", "SweptSolid", [opening_solid]) opening_shape = f.createIfcProductDefinitionShape(None, None, [opening_representation]) opening_element = f.createIfcOpeningElement( create_guid(), owner_history, "Opening", "Door opening", None, opening_placement, opening_shape, None, ) f.createIfcRelVoidsElement(create_guid(), owner_history, None, None, parent, opening_element) return opening_element
def __init__(self, name, guid=None, metadata=None, units="m", parent=None, ifc_settings=None): self.name = name self.parent = parent self._ifc_settings = ifc_settings from ada.core.utils import create_guid self.guid = create_guid() if guid is None else guid units = units.lower() if units not in _Settings.valid_units: raise ValueError(f'Unit type "{units}"') self._units = units self._metadata = metadata if metadata is not None else dict()
def add_properties_to_elem(name, ifc_file, ifc_elem, elem_props): """ :param ifc_file: :param ifc_elem: :param elem_props: :return: """ owner_history = ifc_file.by_type("IfcOwnerHistory")[0] props = create_property_set(name, ifc_file, elem_props) ifc_file.createIfcRelDefinesByProperties( create_guid(), owner_history, "Properties", None, [ifc_elem], props, )
def generate_tpl_ifc_file(file_name, project, organization, creator, schema, units): """ :param file_name: :param project: :param organization: :param creator: :param schema: :param units: :return: """ import time from ada.core.ifc_template import tpl_create timestamp = time.time() timestring = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(timestamp)) application, application_version = "IfcOpenShell", "0.6" project_globalid = create_guid() if units == "m": units_str = "$,.METRE." elif units == "mm": units_str = ".MILLI.,.METRE." else: raise ValueError(f'Unrecognized unit prefix "{units}"') ifc_file = tpl_create( file_name + ".ifc", timestring, organization, creator, schema, application_version, int(timestamp), application, project_globalid, project, units_str, ) return ifc_file