bim2sim.tasks.common package
Submodules
bim2sim.tasks.common.base_tasks module
- class bim2sim.tasks.common.base_tasks.Quit(playground)
Bases:
ITask
Quit interactive tasks
- final = True
- run()
Run tasks.
- single_use = False
- class bim2sim.tasks.common.base_tasks.Reset(playground)
Bases:
ITask
Reset all progress
- classmethod requirements_met(state, history)
Check if all requirements for this tasks are met.
- Args:
state: state of playground history: history of playground
- run()
Run tasks.
- single_use = False
- touches: Tuple[str] = '__reset__'
bim2sim.tasks.common.check_ifc module
- class bim2sim.tasks.common.check_ifc.CheckIfc(playground: Playground)
Bases:
ITask
Check an IFC file, for a number of conditions (missing information, incorrect information, etc) that could lead on future tasks to fatal errors.
- static apply_validation_function(fct: bool, err_name: str, error: list)
Function to apply a validation to an instance, space boundary or port, it stores the error to the list of errors.
- Args:
fct: validation function to be applied err_name: string that define the error error: list of errors
- check_critical_errors(ifc: file, id_list: list)
Checks for critical errors in the IFC file.
- Args:
ifc: ifc file loaded with IfcOpenShell id_list: list of all GUID’s in IFC File
- Raises:
TypeError: if a critical error is found
- static check_critical_uniqueness(id_list: list)
Checks if all GlobalIds are unique.
Only files containing unique GUIDs are valid for bim2sim.
- Args:
id_list: list of all GUID’s in IFC File
- Raises:
TypeError: if loaded file does not have unique GUIDs Warning: if uppercase GUIDs are equal
- static check_ifc_version(ifc: file)
Checks the IFC version.
Only IFC4 files are valid for bim2sim.
- Args:
ifc: ifc file loaded with IfcOpenShell
- Raises:
TypeError: if loaded IFC is not IFC4
- static check_inst(validation_function: Callable, elements: list)
Uses sb_validation/ports/elements functions in order to check each one and adds error to dictionary if object has errors. Args:
- validation_function: function that compiles all the validations
to be performed on the object (sb/port/instance)
elements: list containing all objects to be evaluates
- Returns:
- summary: summarized dictionary of errors, where the key is the
GUID + the ifc_type
- get_html_templates()
Gets all stored html templates that will be used to export the errors summaries
- Returns:
templates: dictionary containing all error html templates
- get_relevant_elements(ifc: file)
Gets all relevant ifc elements based on the plugin’s classes that represent an IFCProduct
- Args:
ifc: IFC file translated with ifcopenshell
- Returns:
ifc_elements: list of IFC instance (Products)
- reads: Tuple[str] = ('ifc_files',)
- run(ifc_files: [<class 'bim2sim.kernel.ifc_file.IfcFileClass'>]) [<class 'dict'>, <class 'dict'>]
Analyzes sub_elements and elements of an IFC file for the validation functions and export the errors found as .json and .html files.
- Args:
- ifc_files: bim2sim IfcFileClass holding the ifcopenshell ifc
instance
- Returns:
error_summary_sub_inst: summary of errors related to sub_elements error_summary_inst: summary of errors related to elements
- validate_elements(inst: list) list
- validate_sub_inst(sub_inst: list) list
- class bim2sim.tasks.common.check_ifc.CheckIfcBPS(playground: Playground)
Bases:
CheckIfc
Check an IFC file, for a number of conditions (missing information, incorrect information, etc.) that could lead on future tasks to fatal errors.
- check_critical_errors(ifc: file, id_list: list)
Checks for critical errors in the IFC file.
- Args:
ifc: ifc file loaded with IfcOpenShell id_list: list of all GUID’s in IFC File
- Raises:
TypeError: if a critical error is found
- check_rel_space_exist()
Checks for the existence of RelatedSpace attribute of IfcRelSpaceBoundaries.
Only IfcRelSpaceBoundaries with an IfcSpace or IfcExternalSpatialElement are valid for bim2sim.
- Raises:
TypeError: if loaded file only contain IfcRelSpaceBoundaries without a valid RelatedSpace.
- check_sub_inst_exist()
Checks for the existence of IfcRelSpaceBoundaries.
Only files containing elements of type ‘IfcRelSpaceBoundary’ are valid for bim2sim.
- Raises:
TypeError: if loaded file does not contain IfcRelSpaceBoundaries
- validate_elements(inst: entity_instance) list
Validation function for an instance that compiles all instance validation functions.
- Args:
inst:IFC instance being checked
- Returns:
error: list of elements error
- validate_sub_inst(bound: entity_instance) list
Validation function for a space boundary that compiles all validation functions.
- Args:
bound: ifc space boundary entity
- Returns:
error: list of errors found in the ifc space boundaries
- class bim2sim.tasks.common.check_ifc.CheckIfcHVAC(playground: Playground)
Bases:
CheckIfc
Check an IFC file for a number of conditions (missing information, incorrect information, etc) that could lead on future tasks to fatal errors.
- validate_elements(inst: entity_instance) list
Validation function for an instance that compiles all instance validation functions.
- Args:
inst: IFC instance being checked
- Returns:
error: list of elements error
- validate_sub_inst(port: entity_instance) list
Validation function for a port that compiles all validation functions.
- Args:
port: IFC port entity
- Returns:
error: list of errors found in the IFC port
bim2sim.tasks.common.create_elements module
- class bim2sim.tasks.common.create_elements.CreateElementsOnIfcTypes(playground: Playground)
Bases:
ITask
Create bim2sim elements based on information of IFC types.
- create_constituent(element: Element, ifc_material_constituents: entity_instance, quality_logger: Element)
- Instantiate the constituent set and its materials and link to
element.
Constituent sets in IFC are used to describe the e.g. windows which consist out of different materials (glass, frame etc.) or mixtures like concrete (sand, cement etc.).
- Args:
element: bim2sim element ifc_material_constituents: ifc entity of layerset quality_logger: element of bim2sim quality logger
- create_layers_and_materials(element: Element)
Create all layers and materials associated with the given element.
Layers and materials are no IfcProducts and have no GUID. They are always associated to IfcProducts. To create the association between Product and layer or material we create layers and materials directly when creating the corresponding element and not directly based on their IFC type in the normal creation process. For more information how materials work in IFC have a look at
- `wiki.osarch.org`_.
_wiki.osarch.org: https://wiki.osarch.org/index.php?title=IFC_-_ Industry_Foundation_Classes/IFC_materials
- Args:
element: the already created bim2sim element
- create_layersets(element: Element, ifc_layerset_entity: entity_instance)
- Instantiate the layerset and its layers and materials and link to
element.
Layersets in IFC are used to describe the layer structure of e.g. walls.
- Args:
element: bim2sim element ifc_layerset_entity: ifc entity of layerset
- create_material(ifc_material_entity: entity_instance)
As materials are unique in IFC we only want to have on material instance per material.
- create_with_validation(entities_dict: dict, warn=True, force=False) Tuple[List[ProductBased], List[Any]]
Instantiate ifc_entities using given element class.
The given ifc entities are used to create bim2sim elements via factory method. After the creation the associated layers and material are created (see create_layers_and_materials). All created elements (including material and layers) are checked against the provided conditions and classified into valid and invalid.
- Args:
entities_dict: dict with ifc entities warn: boolean to warn if something condition fail force: boolean if conditions should be ignored
- Returns:
valid: list of all valid items that fulfill the conditions invalid: list of all elements that do not fulfill the conditions
- filter_by_text(text_filter: TextFilter, ifc_entities: entity_instance, ifc_units: dict) Generator[DecisionBunch, None, Tuple[Dict[Any, Type[ProductBased]], List]]
Generator method filtering ifc elements by given TextFilter.
yields decision bunch for ambiguous results
- get_ifc_types(relevant_elements: List[Type[ProductBased]]) Set[str]
Extract used ifc types from list of elements.
- reads: Tuple[str] = ('ifc_files',)
- run(ifc_files: [<class 'bim2sim.kernel.ifc_file.IfcFileClass'>]) Tuple[Dict[Any, Element], Dict[Any, Element], List[IfcFileClass]]
This task creates the bim2sim elements based on the ifc data.
For each ifc file a factory instance is created. The factory instance allows the easy creation of bim2sim elements based on ifc elements. As we might not want to create bim2sim elements for every existing ifc element, we use the concept of relevant_elements which are taken from the sim_setting relevant_elements. This way the user can describe which bim2sim elements are relevant for the respective simulation and only the fitting ifc elements are taken into account. During the creation of the bim2sim elements validations are performed, to make sure that the resulting bim2sim elements hold valid information.
- Args:
ifc_files: list of ifc files in bim2sim structured format
- Returns:
elements: bim2sim elements created based on ifc data ifc_files: list of ifc files in bim2sim structured format
- set_class_by_user(unknown_entities: list, sim_settings: BaseSimSettings, best_guess_dict: dict)
Ask user for every given ifc_entity to specify matching element class.
This function allows to define unknown classes based on user feedback. To reduce the number of decisions we implemented fuzzy search. If and how fuzzy search is used can be set the sim_settings group_unidentified and fuzzy_threshold. See group_similar_entities() for more information.
- Args:
unknown_entities: list of unknown entities sim_settings: sim_settings used for this project best_guess_dict: dict that holds the best guesses for every element
- touches: Tuple[str] = ('elements', '_initial_elements', 'ifc_files')
bim2sim.tasks.common.create_relations module
- class bim2sim.tasks.common.create_relations.CreateRelations(playground)
Bases:
ITask
Relations of elements, run() method holds detailed information.
- reads: Tuple[str] = ('elements',)
- run(elements: dict[str, bim2sim.elements.base_elements.IFCBased])
Bind ThermalZone to ProductBased/Storey/Building and vice versa.
This is needed as our CreateElements task does not work hierarchic. So we need to create the relations after initial creation. Problem: Following IFC-schema rules a space that is stretched over multiple storeys should only be assigned to one of these storeys. From IFC-Schema: “NOTE: Multi storey spaces shall be spatially contained by only a single building storey, usually it is the building storey where the base of the space lies. TODO: this might me solved via PyOCCTools.obj2_in_obj1 but this needs
all shapes to be existing for ThermalZone instances and Storeys
“
- Args:
elements: dict[guid: element]
bim2sim.tasks.common.deserialize_elements module
- class bim2sim.tasks.common.deserialize_elements.DeserializeElements(playground)
Bases:
ITask
Deserialize elements, run() method holds detailed information.
- run()
Deserializes the elements from a previous run.
Loads the serialized_elements from a previous run from the pickled object.
- Returns:
- serialized_elements: dict[guid: serializedElement] of serialized
elements
- single_use = True
- touches: Tuple[str] = ('elements',)
bim2sim.tasks.common.inner_loop_remover module
This module contains functions which, given a TopoDS shapes with holes (“inner loops”), calculate an equivalent shape without holes by adding cuts along triangulation edges. Using the triangulation as a graph, it finds a spanning tree between the main polygon and its holes using Kruskal’s algorithm and places the cuts along the edges of this spanning tree.
- bim2sim.tasks.common.inner_loop_remover.convex_decomposition(shape: TopoDS_Shape, opening_shapes: List[TopoDS_Shape] = []) List[TopoDS_Shape]
- bim2sim.tasks.common.inner_loop_remover.convex_decomposition_base(shape: TopoDS_Shape, opening_shapes: List[TopoDS_Shape] = []) List[List[Tuple[float, float, float]]]
Convex decomposition base: removes common edges of triangles unless a non-convex shape is created. In case of openings: In a first round, remove all cutting triangle edges with the opening polygons regardless of non-convex shapes. Then, check for resulting angles. This may lead to non-convex shapes, but should work in most cases.
- bim2sim.tasks.common.inner_loop_remover.fuse_pieces(pieces: List[List[Tuple[float, float, float]]], shapes_to_consider: List[TopoDS_Shape] = []) List[List[Tuple[float, float, float]]]
- bim2sim.tasks.common.inner_loop_remover.is_convex_no_holes(shape: TopoDS_Shape) bool
check if TopoDS_Shape is convex. Returns False if shape is non-convex
- bim2sim.tasks.common.inner_loop_remover.is_convex_slow(shape: TopoDS_Shape) bool
Computational expensive check if a TopoDS_Shape is convex. Args:
shape: TopoDS_Shape
- Returns:
bool, True if shape is convex.
- bim2sim.tasks.common.inner_loop_remover.is_polygon_convex_no_holes(pnts: List[Tuple[float, float, float]]) bool
check if polygon made from tuples of floats is convex. Returns False if shape is non-convex
- bim2sim.tasks.common.inner_loop_remover.remove_inner_loops(shape: TopoDS_Shape) TopoDS_Shape
bim2sim.tasks.common.load_ifc module
- class bim2sim.tasks.common.load_ifc.LoadIFC(playground)
Bases:
ITask
Load all IFC files from PROJECT.ifc_base path.
This tasks reads the IFC files of one or multiple domains inside bim2sim.
- Returns:
ifc: list of one or multiple IfcFileClass elements
- load_ifc_files(base_path: Path)
Load all ifc files in given base_path or a specific file in this path
- Loads the ifc files inside the different domain folders in the base
path, and initializes the bim2sim ifc file classes.
- Args:
- base_path: Pathlib path that holds the different domain folders,
which hold the ifc files.
- run()
Run tasks.
- touches: Tuple[str] = ('ifc_files',)
bim2sim.tasks.common.serialize_elements module
- class bim2sim.tasks.common.serialize_elements.SerializeElements(playground)
Bases:
ITask
Serialize element structure, run() method holds detailed information.
- reads: Tuple[str] = ('elements',)
- run(elements: dict) Tuple[Dict]
Make the element structure serializable.
As due to swigPy objects coming from IfcOpenShell we can’t directly serialize a whole bim2sim project or even the elements structure with serializers like pickle. To still keep the element structure information after a project run, we just copy the relevant information like the attributes from the AttributeManager, guid and type of the element to a simple SerializedElement instance and store it with pickle.
- Args:
elements: dict[guid: element] of bim2sim element structure
- Returns:
- serialized_elements: dict[guid: serializedElement] of serialized
elements
- single_use = True
- touches: Tuple[str] = ('serialized_elements',)
bim2sim.tasks.common.weather module
- class bim2sim.tasks.common.weather.Weather(playground)
Bases:
ITask
Task to get the weather file for later simulation
- check_file_ending(weather_file: WindowsPath)
Check if the file ending fits the simulation model type.
- get_location_lat_long_from_ifc(elements: dict) [<class 'float'>]
Returns the location in form of latitude and longitude based on IfcSite.
The location of the site and therefore the building are taken from the IfcSite in form of latitude and longitude. Latitude and Longitude each are a tuple of (degrees, minutes, seconds) and, optionally, millionths of seconds. See IfcSite Documentation for further information. Args:
elements: dict with bim2sim elements
- Returns:
latitude, longitude: two float values for latitude and longitude
- get_location_name(latitude: tuple, longitude: tuple) str
Returns the name of the location based on latitude and longitude.
- Args:
latitude: tuple of degrees, minutes and seconds longitude: tuple of degrees, minutes and seconds
- Returns:
location_name: str of the location name
- get_weatherfile_from_dwd(lat: tuple, long: tuple)
- reads: Tuple[str] = ('elements',)
- run(elements: dict)
Run tasks.
- touches: Tuple[str] = ('weather_file',)