bim2sim.kernel package

Kernel module of bim2sim

Holds central target simulation independent logic.

exception bim2sim.kernel.IFCDomainError

Bases: Exception

Exception raised if IFCDomain of file and element do not fit.

Subpackages

Submodules

bim2sim.kernel.decorators module

class bim2sim.kernel.decorators.cached_property(func, name=None, doc=None)

Bases: property

bim2sim.kernel.decorators.log(name)

Decorator for logging of entering and leaving method

bim2sim.kernel.ifc_file module

class bim2sim.kernel.ifc_file.IfcFileClass(ifc_path: Path, reset_guids: bool = False, ifc_domain: IFCDomain | None = None)

Bases: object

Combine IfcOpenShell file instance, finder and units together.

Especially if we handle multiple IFC files this dataclass helps us to keep track which finder and units belong to which ifc file.

Args:

ifc_path: Pathlib object that points to ifc file reset_guids: Boolean that determine if GUIDs should be reset ifc_domain: Domain of the given ifc file if this is known

get_ifc_units() dict

Returns dict to translate IFC units to pint units

To use units from IFC we get all unit definitions from the ifc and their corresponding measurement elements and map them to pint units.

Returns:

dict where key is the IfcMeasurement and value the pint unit definition. e.g. ‘IfcLengthMeasure’: meter

initialize_finder(finder_path)
static load_ifcopenshell_file(ifc_path) file

Loads the IfcOpenShell file instance

bim2sim.kernel.log module

class bim2sim.kernel.log.AudienceFilter(audience, name='')

Bases: Filter

filter(record: LogRecord) bool

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class bim2sim.kernel.log.CustomFormatter(fmt)

Bases: Formatter

Custom logging design based on https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output

format(record)

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class bim2sim.kernel.log.ThreadLogFilter(thread_name, *args, **kwargs)

Bases: Filter

This filter only show log entries for specified thread name.

filter(record)

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

bim2sim.kernel.log.default_logging_setup(verbose=False)

Setup for logging module

This creates the following: * the general logger with name bim2sim as default logger * the file output file bim2sim.log where the logs are stored * the logger quality_logger which stores all information about the quality of existing information of the BIM model

bim2sim.kernel.log.get_user_logger(name)