mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
IfcFM panel now autodetects available engines with names and descriptions
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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", ""),
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user