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');
This commit is contained in:
Andrej730
2023-08-22 18:09:04 +05:00
parent 21f4fb169f
commit 2128eda87b
3 changed files with 26 additions and 14 deletions
+5 -2
View File
@@ -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.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
self.file.wrapped_data.header.file_name.originating_system = "{} {}".format( 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): def sync_all_objects(self):
@@ -162,7 +162,7 @@ class IfcExporter:
return "BlenderBIM" return "BlenderBIM"
def get_application_version(self): def get_application_version(self):
return ".".join( version = ".".join(
[ [
str(x) str(x)
for x in [ for x in [
@@ -172,6 +172,9 @@ class IfcExporter:
][0] ][0]
] ]
) )
if blenderbim.bim.last_commit_hash != "8888888":
version += f"-{blenderbim.bim.last_commit_hash[:7]}"
return version
class IfcExportSettings: class IfcExportSettings:
+3 -12
View File
@@ -464,6 +464,7 @@ class BIM_PT_tab_quality_control(Panel):
def draw(self, context): def draw(self, context):
pass pass
class BIM_PT_tab_clash_detection(Panel): class BIM_PT_tab_clash_detection(Panel):
bl_label = "Clash Detection" bl_label = "Clash Detection"
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
@@ -477,6 +478,7 @@ class BIM_PT_tab_clash_detection(Panel):
def draw(self, context): def draw(self, context):
pass pass
class BIM_PT_tab_sandbox(Panel): class BIM_PT_tab_sandbox(Panel):
bl_label = "Sandbox" bl_label = "Sandbox"
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
@@ -658,24 +660,13 @@ class UIData:
@classmethod @classmethod
def version(cls): def version(cls):
return ".".join( return tool.Blender.get_blenderbim_version()
[
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]
]
)
def draw_statusbar(self, context): def draw_statusbar(self, context):
if not UIData.is_loaded: if not UIData.is_loaded:
UIData.load() UIData.load()
text = f"BlenderBIM Add-on v{UIData.data['version']}" 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) self.layout.label(text=text)
+18
View File
@@ -20,8 +20,10 @@ import bpy
import json import json
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import blenderbim.tool as tool
import blenderbim.bim
from mathutils import Vector from mathutils import Vector
from pathlib import Path from pathlib import Path
import addon_utils
VIEWPORT_ATTRIBUTES = [ VIEWPORT_ATTRIBUTES = [
@@ -588,3 +590,19 @@ class Blender:
child_obj = tool.Blender.get_object_from_guid(child_guid) child_obj = tool.Blender.get_object_from_guid(child_guid)
if child_obj: if child_obj:
yield 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