diff --git a/src/ifcblenderexport/Makefile b/src/ifcblenderexport/Makefile index f3af203803..197ddb8e4d 100644 --- a/src/ifcblenderexport/Makefile +++ b/src/ifcblenderexport/Makefile @@ -38,10 +38,12 @@ endif cd dist/blenderbim/libs/site/packages/ifcopenshell/util && rm -f geolocation.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && rm -f selector.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && rm -f unit.py + cd dist/blenderbim/libs/site/packages/ifcopenshell/util && rm -f pset.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/util/element.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/util/geolocation.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/util/selector.py cd dist/blenderbim/libs/site/packages/ifcopenshell/util && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/util/unit.py + cd dist/blenderbim/libs/site/packages/ifcopenshell/util && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcopenshell-python/ifcopenshell/util/pset.py # Provides Python OCC functionality for cutting IFC geometry for construction documentation mkdir dist/working diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index c089abab20..943bf0d5f3 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -836,16 +836,30 @@ class AddQto(bpy.types.Operator): bl_label = "Add Qto" def execute(self, context): + self.applicable_qtos_cache = {} name = bpy.context.active_object.BIMObjectProperties.qto_name if name not in ifcopenshell.util.pset.qtos: return {"FINISHED"} - qto = bpy.context.active_object.BIMObjectProperties.qtos.add() - qto.name = name - for prop_name in ifcopenshell.util.pset.qtos[name]["HasPropertyTemplates"].keys(): - prop = qto.properties.add() - prop.name = prop_name + for obj in bpy.context.selected_objects: + if "/" not in obj.name or obj.BIMObjectProperties.qtos.find(name) != -1: + continue + applicable_qtos = self.get_applicable_qtos(obj.name.split("/")[0]) + if name not in applicable_qtos: + continue + qto = obj.BIMObjectProperties.qtos.add() + qto.name = name + for prop_name in ifcopenshell.util.pset.qtos[name]["HasPropertyTemplates"].keys(): + prop = qto.properties.add() + prop.name = prop_name return {"FINISHED"} + def get_applicable_qtos(self, ifc_class): + if ifc_class not in self.applicable_qtos_cache: + self.applicable_qtos_cache[ifc_class] = ifcopenshell.util.pset.get_applicable_psetqtos( + bpy.context.scene.BIMProperties.export_schema, ifc_class, is_qto=True + ) + return self.applicable_qtos_cache[ifc_class] + class AddPset(bpy.types.Operator): bl_idname = "bim.add_pset" @@ -899,7 +913,13 @@ class RemoveQto(bpy.types.Operator): index: bpy.props.IntProperty() def execute(self, context): - bpy.context.active_object.BIMObjectProperties.qtos.remove(self.index) + name = bpy.context.active_object.BIMObjectProperties.qtos[self.index].name + for obj in bpy.context.selected_objects: + if "/" not in obj.name: + continue + index = obj.BIMObjectProperties.qtos.find(name) + if index != -1: + obj.BIMObjectProperties.qtos.remove(index) return {"FINISHED"}