When updating representations, the existing representation type is prioritised unless you tell it otherwise. See #1748.

This commit is contained in:
Dion Moult
2021-10-21 18:39:14 +11:00
parent d6cb94c6f1
commit 525e6debd5
3 changed files with 27 additions and 0 deletions
@@ -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"
@@ -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"
@@ -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: