diff --git a/src/blenderbim/blenderbim/bim/module/root/data.py b/src/blenderbim/blenderbim/bim/module/root/data.py index b5463f3194..07b107d51e 100644 --- a/src/blenderbim/blenderbim/bim/module/root/data.py +++ b/src/blenderbim/blenderbim/bim/module/root/data.py @@ -19,7 +19,7 @@ from collections import defaultdict import bpy import ifcopenshell.util.element -from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc +from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc, get_class_suggestions import blenderbim.tool as tool import blenderbim.bim.helper from blenderbim.bim.ifc import IfcStore @@ -110,28 +110,20 @@ class IfcClassData: @classmethod def ifc_classes_suggestions(cls): + # suggestions : dict[class_name: list[dict[predefined_type, name(optional)]]] suggestions = defaultdict(list) - suggestions.update( - { - "IfcActuator": ["Electric Strike"], - "IfcAirTerminalBox": ["VAV Box"], - "IfcCableSegment": ["Lighting Rod"], - "IfcCovering": ["Flashing", "Capping"], - "IfcFurniture": ["Signage"], - "IfcPlate": ["Glazing", "Glass", "Pane"], - "IfcSensor": ["Card Reader", "Fob Reader"], - "IfcSlab": ["Hob"], - "IfcSwitchingDevice": ["Reed Switch", "Electric Isolating Switch"], - "IfcUnitaryEquipment": ["Fan Coil Unit"], - "IfcWall": ["Glazing", "Glass", "Pane"], - "IfcWindow": ["Glazing", "Glass", "Pane"], - } - ) version = tool.Ifc.get_schema() for ifc_class, _, _ in cls.data["ifc_classes"]: class_doc = get_entity_doc(version, ifc_class) or {} predefined_types = class_doc.get("predefined_types", {}) - suggestions[ifc_class].extend(predefined_types.keys()) + for predefined_type in predefined_types.keys(): + suggestions[ifc_class].append({"predefined_type": predefined_type}) + + class_suggestions = get_class_suggestions(version, ifc_class) + if not class_suggestions: + continue + for suggestion_dict in class_suggestions: + suggestions[ifc_class].append(suggestion_dict) return suggestions @classmethod diff --git a/src/blenderbim/blenderbim/bim/operator.py b/src/blenderbim/blenderbim/bim/operator.py index 97fe9d9e90..2b5cf9003f 100644 --- a/src/blenderbim/blenderbim/bim/operator.py +++ b/src/blenderbim/blenderbim/bim/operator.py @@ -870,7 +870,13 @@ class BIM_OT_enum_property_search(bpy.types.Operator): if not isinstance(values, (tuple, list)): values = [values] for value in values: - self.add_item(identifier=key, name=key + " > " + value, predefined_type=value.upper()) + predefined_type = value["predefined_type"].upper() + name = value.get("name") + self.add_item( + identifier=key, + name=f"{key} > {name if name else predefined_type }", + predefined_type=predefined_type, + ) class EditBlenderCollection(bpy.types.Operator): diff --git a/src/ifcopenshell-python/ifcopenshell/util/doc.py b/src/ifcopenshell-python/ifcopenshell/util/doc.py index 664d9561cc..c852120909 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/doc.py +++ b/src/ifcopenshell-python/ifcopenshell/util/doc.py @@ -64,16 +64,19 @@ SCHEMA_FILES = { "entities": BASE_MODULE_PATH / "schema/ifc2x3_entities.json", "properties": BASE_MODULE_PATH / "schema/ifc2x3_properties.json", "types": BASE_MODULE_PATH / "schema/ifc2x3_types.json", + "classes_suggestions": BASE_MODULE_PATH / "schema/ifc_classes_suggestions.json", }, "IFC4": { "entities": BASE_MODULE_PATH / "schema/ifc4_entities.json", "properties": BASE_MODULE_PATH / "schema/ifc4_properties.json", "types": BASE_MODULE_PATH / "schema/ifc4_types.json", + "classes_suggestions": BASE_MODULE_PATH / "schema/ifc_classes_suggestions.json", }, "IFC4X3": { "entities": BASE_MODULE_PATH / "schema/ifc4x3_entities.json", "properties": BASE_MODULE_PATH / "schema/ifc4x3_properties.json", "types": BASE_MODULE_PATH / "schema/ifc4x3_types.json", + "classes_suggestions": BASE_MODULE_PATH / "schema/ifc_classes_suggestions.json", }, } @@ -105,6 +108,14 @@ def get_schema_by_name(version): return schema_by_name[version] +def get_class_suggestions(version, class_name): + db = get_db(version) + if not db: + return + class_suggestions = db["classes_suggestions"].get(class_name) + return class_suggestions + + def get_entity_doc(version, entity_name, recursive=True): db = get_db(version) if db: diff --git a/src/ifcopenshell-python/ifcopenshell/util/schema/ifc_classes_suggestions.json b/src/ifcopenshell-python/ifcopenshell/util/schema/ifc_classes_suggestions.json new file mode 100644 index 0000000000..fc1d27f8c9 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/util/schema/ifc_classes_suggestions.json @@ -0,0 +1,110 @@ +{ + "IfcActuator": [ + { + "name": "Electric Strike", + "predefined_type": "NOTDEFINED" + } + ], + "IfcAirTerminalBox": [ + { + "name": "VAV Box", + "predefined_type": "NOTDEFINED" + } + ], + "IfcCableSegment": [ + { + "name": "Lighting Rod", + "predefined_type": "NOTDEFINED" + } + ], + "IfcCovering": [ + { + "name": "Flashing", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Capping", + "predefined_type": "NOTDEFINED" + } + ], + "IfcFurniture": [ + { + "name": "Signage", + "predefined_type": "NOTDEFINED" + } + ], + "IfcPlate": [ + { + "name": "Glazing", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Glass", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Pane", + "predefined_type": "NOTDEFINED" + } + ], + "IfcSensor": [ + { + "name": "Card Reader", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Fob Reader", + "predefined_type": "NOTDEFINED" + } + ], + "IfcSlab": [ + { + "name": "Hob", + "predefined_type": "NOTDEFINED" + } + ], + "IfcSwitchingDevice": [ + { + "name": "Reed Switch", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Electric Isolating Switch", + "predefined_type": "NOTDEFINED" + } + ], + "IfcUnitaryEquipment": [ + { + "name": "Fan Coil Unit", + "predefined_type": "NOTDEFINED" + } + ], + "IfcWall": [ + { + "name": "Glazing", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Glass", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Pane", + "predefined_type": "NOTDEFINED" + } + ], + "IfcWindow": [ + { + "name": "Glazing", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Glass", + "predefined_type": "NOTDEFINED" + }, + { + "name": "Pane", + "predefined_type": "NOTDEFINED" + } + ] +} \ No newline at end of file