diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index 7ef14aa8e0..7b9a40afcd 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -200,6 +200,9 @@ class UpdateRepresentation(bpy.types.Operator): ) ) + if not self.ifc_representation_class: + self.ifc_representation_class = self.auto_detect_ifc_representation_class(product, old_representation) or "" + representation_data = { "context": context_of_items, "blender_object": obj, @@ -245,6 +248,25 @@ class UpdateRepresentation(bpy.types.Operator): if obj.data.BIMMeshProperties.ifc_parameters: bpy.ops.bim.get_representation_ifc_parameters() + def auto_detect_ifc_representation_class(self, element, representation): + material = ifcopenshell.util.element.get_material(element) + + if material.is_a("IfcMaterialProfileSetUsage"): + return "IfcExtrudedAreaSolid/IfcMaterialProfileSetUsage" + + extruded_areas = [e for e in self.file.traverse(representation) if e.is_a() == "IfcExtrudedAreaSolid"] + + if len(extruded_areas) != 1: + return None # It's too complex for us to derive topologically right now + + profile_def = extruded_areas[0].SweptArea + + if profile_def.is_a() == "IfcRectangleProfileDef": + return "IfcExtrudedAreaSolid/IfcRectangleProfileDef" + elif profile_def.is_a() == "IfcCircleProfileDef": + return "IfcExtrudedAreaSolid/IfcCircleProfileDef" + return "IfcExtrudedAreaSolid/IfcArbitraryProfileDefWithVoids" + class UpdateParametricRepresentation(bpy.types.Operator): bl_idname = "bim.update_parametric_representation" diff --git a/src/blenderbim/blenderbim/bim/module/geometry/ui.py b/src/blenderbim/blenderbim/bim/module/geometry/ui.py index dbca727a1f..4917de183e 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/ui.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/ui.py @@ -109,6 +109,10 @@ class BIM_PT_mesh(Panel): row = layout.row() row.operator("bim.update_representation") + row = layout.row() + op = row.operator("bim.update_representation", text="Update Mesh As Tessellation") + op.ifc_representation_class = "IfcTessellatedFaceSet" + row = layout.row() op = row.operator("bim.update_representation", text="Update Mesh As Rectangle Extrusion") op.ifc_representation_class = "IfcExtrudedAreaSolid/IfcRectangleProfileDef" diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 9c8f66beae..5ab4434d08 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -102,6 +102,7 @@ class Geometry(blenderbim.core.tool.Geometry): ifc_import_settings = blenderbim.bim.import_ifc.IfcImportSettings.factory(bpy.context, None, logger) element = tool.Ifc.get_entity(obj) settings = ifcopenshell.geom.settings() + settings.set(settings.WELD_VERTICES, True) if representation.ContextOfItems.ContextIdentifier == "Body": if element.is_a("IfcTypeProduct") or enable_dynamic_voids: