mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 13:58:12 +00:00
Recent IFC projects - show schema in the tooltip
Example - https://i.imgur.com/0op89zh.png
This commit is contained in:
@@ -28,6 +28,7 @@ import datetime
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
import ifcopenshell.util.file
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
import ifcopenshell.util.geolocation
|
import ifcopenshell.util.geolocation
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
@@ -668,9 +669,9 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
|
|||||||
if not filepath:
|
if not filepath:
|
||||||
return tooltip
|
return tooltip
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
tooltip += f".\n\n"
|
tooltip += f".\n"
|
||||||
if not filepath.exists():
|
if not filepath.exists():
|
||||||
tooltip += "File does not exist"
|
tooltip += "\nFile does not exist"
|
||||||
return tooltip
|
return tooltip
|
||||||
|
|
||||||
def get_modified_date(st_mtime: float) -> str:
|
def get_modified_date(st_mtime: float) -> str:
|
||||||
@@ -691,8 +692,13 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
|
|||||||
size = size_bytes / (1024 * 1024)
|
size = size_bytes / (1024 * 1024)
|
||||||
return f"{size:.1f} MiB"
|
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()
|
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)}"
|
tooltip += f"\nSize: {get_file_size(file_stat.st_size)}"
|
||||||
|
|
||||||
return tooltip
|
return tooltip
|
||||||
|
|||||||
Reference in New Issue
Block a user