diff --git a/src/blenderbim/blenderbim/bim/module/fm/data.py b/src/blenderbim/blenderbim/bim/module/fm/data.py new file mode 100644 index 0000000000..ceb4b2e8ef --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/fm/data.py @@ -0,0 +1,48 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2023 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import os +import ifcfm +import importlib + + +def refresh(): + FMData.is_loaded = False + + +class FMData: + data = {} + is_loaded = False + + @classmethod + def load(cls): + cls.is_loaded = True + cls.data = {} + cls.data["engine"] = cls.engine() + + @classmethod + def engine(cls): + results = [] + fm_dir = os.path.dirname(ifcfm.__file__) + for f in os.listdir(fm_dir): + if f.endswith(".py") and not f.startswith("_"): + preset = os.path.splitext(f)[0] + module = importlib.import_module(f"ifcfm.{preset}") + config = getattr(module, "config") + results.append((preset, config["name"], config["description"])) + return results diff --git a/src/blenderbim/blenderbim/bim/module/fm/prop.py b/src/blenderbim/blenderbim/bim/module/fm/prop.py index 696c27a084..f4a1868645 100644 --- a/src/blenderbim/blenderbim/bim/module/fm/prop.py +++ b/src/blenderbim/blenderbim/bim/module/fm/prop.py @@ -17,6 +17,7 @@ # along with BlenderBIM Add-on. If not, see . import bpy +from blenderbim.bim.module.fm.data import FMData from blenderbim.bim.prop import StrProperty from bpy.types import PropertyGroup from bpy.props import ( @@ -31,21 +32,18 @@ from bpy.props import ( ) +def get_engine(self, context): + if not FMData.is_loaded: + FMData.load() + return FMData.data["engine"] + + class BIMFMProperties(PropertyGroup): ifc_file: StringProperty(default="", name="IFC File") ifc_files: CollectionProperty(name="IFC Files", type=StrProperty) spreadsheet_files: CollectionProperty(name="Spreadsheets", type=StrProperty) should_load_from_memory: BoolProperty(default=False, name="Load from Memory") - engine: EnumProperty( - items=[ - ("aohbsem", "AOH-BSEM", ""), - ("basic", "Basic", ""), - ("cobie24", "COBie 2.4", ""), - ("cobie3", "COBie 3", ""), - ], - name="Engine", - default="cobie24", - ) + engine: EnumProperty(items=get_engine, name="Engine") format: EnumProperty( items=[ ("csv", "csv", ""), diff --git a/src/blenderbim/blenderbim/bim/module/fm/ui.py b/src/blenderbim/blenderbim/bim/module/fm/ui.py index 502e463e19..ca5efe36f1 100644 --- a/src/blenderbim/blenderbim/bim/module/fm/ui.py +++ b/src/blenderbim/blenderbim/bim/module/fm/ui.py @@ -19,6 +19,7 @@ import blenderbim.tool as tool from bpy.types import Panel from blenderbim.bim.ifc import IfcStore +from blenderbim.bim.module.fm.data import FMData class BIM_PT_fm(Panel): @@ -30,6 +31,9 @@ class BIM_PT_fm(Panel): bl_parent_id = "BIM_PT_tab_handover" def draw(self, context): + if not FMData.is_loaded: + FMData.load() + layout = self.layout layout.use_property_split = True diff --git a/src/ifcfm/ifcfm/basic.py b/src/ifcfm/ifcfm/basic.py index b7d475b181..61725fc533 100644 --- a/src/ifcfm/ifcfm/basic.py +++ b/src/ifcfm/ifcfm/basic.py @@ -234,6 +234,8 @@ def get_property(psets, pset_name, prop_name, decimals=None): config = { + "name": "IFC Basic", + "description": "buildingSMART standardised properties related to asset management and handover", "colours": { "h": "dddddd", # Header data "p": "dc8774", # Primary identification data diff --git a/src/ifcfm/ifcfm/cobie24.py b/src/ifcfm/ifcfm/cobie24.py index a2b8503550..f1f4f74dbe 100644 --- a/src/ifcfm/ifcfm/cobie24.py +++ b/src/ifcfm/ifcfm/cobie24.py @@ -1036,6 +1036,8 @@ def get_sheet_name(element): config = { + "name": "COBie 2.4", + "description": "Construction-Operations Building information exchange specification by NBIMS-US and BS 1192-4:2014.", "colours": { "h": "c0c0c0", # Header data "r": "ffff99", # Required diff --git a/src/ifcfm/ifcfm/cobie24legacy.py b/src/ifcfm/ifcfm/cobie24legacy.py index 8b50dfa8a4..3b81b17a42 100644 --- a/src/ifcfm/ifcfm/cobie24legacy.py +++ b/src/ifcfm/ifcfm/cobie24legacy.py @@ -1143,6 +1143,8 @@ def get_sheet_name(element): config = { + "name": "COBie 2.4 Legacy", + "description": "A port of the original implementation of COBie by Prairie Sky Consulting for historical preservation", "colours": { "h": "c0c0c0", # Header data "r": "ffff99", # Required