From 7b135180a82565e1769caa83bc45cb3127aa73b4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 22 Aug 2023 18:09:04 +0500 Subject: [PATCH] Save blenderbim last commit hash to the ifc header Now it's possible to identify blenderbim version from .ifc file which is useful for debugging Example: FILE_NAME('test.ifc','2023-08-22T18:07:07+05:00',(),(),'IfcOpenShell v0.7.0-fc50bdd3a','BlenderBIM 0.0.999999-64bc7af','Nobody'); --- src/blenderbim/blenderbim/bim/export_ifc.py | 7 +++++-- src/blenderbim/blenderbim/bim/ui.py | 15 +++------------ src/blenderbim/blenderbim/tool/blender.py | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/export_ifc.py b/src/blenderbim/blenderbim/bim/export_ifc.py index 50412c2354..5813e8081a 100644 --- a/src/blenderbim/blenderbim/bim/export_ifc.py +++ b/src/blenderbim/blenderbim/bim/export_ifc.py @@ -82,7 +82,7 @@ class IfcExporter: ) self.file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version) self.file.wrapped_data.header.file_name.originating_system = "{} {}".format( - self.get_application_name(), self.get_application_version() + self.get_application_name(), tool.Blender.get_blenderbim_version() ) def sync_all_objects(self): @@ -162,7 +162,7 @@ class IfcExporter: return "BlenderBIM" def get_application_version(self): - return ".".join( + version = ".".join( [ str(x) for x in [ @@ -172,6 +172,9 @@ class IfcExporter: ][0] ] ) + if blenderbim.bim.last_commit_hash != "8888888": + version += f"-{blenderbim.bim.last_commit_hash[:7]}" + return version class IfcExportSettings: diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index 03c8514ee1..7a568e85fa 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -464,6 +464,7 @@ class BIM_PT_tab_quality_control(Panel): def draw(self, context): pass + class BIM_PT_tab_clash_detection(Panel): bl_label = "Clash Detection" bl_space_type = "PROPERTIES" @@ -477,6 +478,7 @@ class BIM_PT_tab_clash_detection(Panel): def draw(self, context): pass + class BIM_PT_tab_sandbox(Panel): bl_label = "Sandbox" bl_space_type = "PROPERTIES" @@ -658,24 +660,13 @@ class UIData: @classmethod def version(cls): - return ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) + return tool.Blender.get_blenderbim_version() def draw_statusbar(self, context): if not UIData.is_loaded: UIData.load() text = f"BlenderBIM Add-on v{UIData.data['version']}" - if blenderbim.bim.last_commit_hash != "8888888": - text += f"-{blenderbim.bim.last_commit_hash[:7]}" self.layout.label(text=text) diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index f3702bb801..0ce77b6d1a 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -20,8 +20,10 @@ import bpy import json import ifcopenshell.api import blenderbim.tool as tool +import blenderbim.bim from mathutils import Vector from pathlib import Path +import addon_utils VIEWPORT_ATTRIBUTES = [ @@ -588,3 +590,19 @@ class Blender: child_obj = tool.Blender.get_object_from_guid(child_guid) if child_obj: yield child_obj + + @classmethod + def get_blenderbim_version(cls): + version = ".".join( + [ + str(x) + for x in [ + addon.bl_info.get("version", (-1, -1, -1)) + for addon in addon_utils.modules() + if addon.bl_info["name"] == "BlenderBIM" + ][0] + ] + ) + if blenderbim.bim.last_commit_hash != "8888888": + version += f"-{blenderbim.bim.last_commit_hash[:7]}" + return version