From 5655df20811ab7acff7b629b2fd62ab0ded4746c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 1 Jul 2024 13:46:31 +0500 Subject: [PATCH] Recent IFC projects - show schema in the tooltip Example - https://i.imgur.com/0op89zh.png --- .../blenderbim/bim/module/project/operator.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index 2f4876af24..032d409f40 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -28,6 +28,7 @@ import datetime import numpy as np import ifcopenshell import ifcopenshell.api +import ifcopenshell.util.file import ifcopenshell.util.selector import ifcopenshell.util.geolocation import ifcopenshell.util.representation @@ -668,9 +669,9 @@ class LoadProject(bpy.types.Operator, IFCFileSelector): if not filepath: return tooltip filepath = Path(filepath) - tooltip += f".\n\n" + tooltip += f".\n" if not filepath.exists(): - tooltip += "File does not exist" + tooltip += "\nFile does not exist" return tooltip def get_modified_date(st_mtime: float) -> str: @@ -691,8 +692,13 @@ class LoadProject(bpy.types.Operator, IFCFileSelector): size = size_bytes / (1024 * 1024) return f"{size:.1f} MiB" + extractor = ifcopenshell.util.file.IfcHeaderExtractor(str(filepath)) + header_metadata = extractor.extract() + if schema := header_metadata.get("schema_name"): + tooltip += f"\nSchema: {schema}" + file_stat = filepath.stat() - tooltip += f"Modified: {get_modified_date(file_stat.st_mtime)}" + tooltip += f"\nModified: {get_modified_date(file_stat.st_mtime)}" tooltip += f"\nSize: {get_file_size(file_stat.st_size)}" return tooltip