From c97e1079e85662e1879455184b271d8053175b33 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 20 Mar 2023 16:36:38 +1100 Subject: [PATCH] See #2866. Fix issue where annotation should be able to use 3D coordinates (i.e. Model context type) for elevations and sections where it makes more sense. --- src/blenderbim/blenderbim/bim/import_ifc.py | 4 ++-- src/blenderbim/blenderbim/tool/drawing.py | 5 ++++- src/blenderbim/test/tool/test_drawing.py | 4 ++++ .../api/geometry/add_representation.py | 14 ++++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index f8b42ec162..b728c39e64 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -302,12 +302,12 @@ class IfcImporter: ) if self.body_contexts: self.settings.set_context_ids(self.body_contexts) - # Annotation is to accommodate broken Revit files + # Annotation ContextType is to accommodate broken Revit files # See https://github.com/Autodesk/revit-ifc/issues/187 self.plan_contexts = [ c.id() for c in self.file.by_type("IfcGeometricRepresentationContext") - if c.ContextType in ["Plan", "Annotation"] + if c.ContextType in ["Plan", "Annotation"] or c.ContextIdentifier == "Annotation" ] if self.plan_contexts: self.settings_2d.set_context_ids(self.plan_contexts) diff --git a/src/blenderbim/blenderbim/tool/drawing.py b/src/blenderbim/blenderbim/tool/drawing.py index 3475e32023..fe0d05e44d 100644 --- a/src/blenderbim/blenderbim/tool/drawing.py +++ b/src/blenderbim/blenderbim/tool/drawing.py @@ -191,7 +191,9 @@ class Drawing(blenderbim.core.tool.Drawing): @classmethod def get_annotation_context(cls, target_view): - return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Annotation", target_view) + if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW"): + return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Plan", "Annotation", target_view) + return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Annotation", target_view) @classmethod def get_body_context(cls): @@ -325,6 +327,7 @@ class Drawing(blenderbim.core.tool.Drawing): ifc_importer = blenderbim.bim.import_ifc.IfcImporter(ifc_import_settings) ifc_importer.file = tool.Ifc.get() ifc_importer.calculate_unit_scale() + ifc_importer.process_context_filter() ifc_importer.create_generic_elements(elements) for obj in ifc_importer.added_data.values(): tool.Collector.assign(obj) diff --git a/src/blenderbim/test/tool/test_drawing.py b/src/blenderbim/test/tool/test_drawing.py index ee62459af3..6c538a2565 100644 --- a/src/blenderbim/test/tool/test_drawing.py +++ b/src/blenderbim/test/tool/test_drawing.py @@ -217,8 +217,12 @@ class TestGetAnnotationContext(NewFile): context = ifc.createIfcGeometricRepresentationSubContext( ContextType="Plan", ContextIdentifier="Annotation", TargetView="PLAN_VIEW" ) + context2 = ifc.createIfcGeometricRepresentationSubContext( + ContextType="Model", ContextIdentifier="Annotation", TargetView="ELEVATION_VIEW" + ) tool.Ifc.set(ifc) assert subject.get_annotation_context("PLAN_VIEW") == context + assert subject.get_annotation_context("ELEVATION_VIEW") == context2 class TestGetBodyContext(NewFile): diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index a136a43ae8..9754043326 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -684,12 +684,14 @@ class Usecase: def create_annotation3d_representation(self): items = [] - curves = self.create_curves(should_exclude_faces=True, is_2d=False) - if curves: - items.append(self.file.createIfcGeometricCurveSet(curves)) - surfaces = self.create_curve_bounded_planes() - if surfaces: - items.append(self.file.createIfcGeometricSet(surfaces)) + if isinstance(self.settings["geometry"], bpy.types.Mesh) and len(self.settings["geometry"].polygons): + items = self.create_annotation_fill_areas(is_2d=False) + else: + items = [self.file.createIfcGeometricCurveSet(self.create_curves(is_2d=False))] + # TODO Unsure when it is appropriate to use curve bounded planes + # surfaces = self.create_curve_bounded_planes() + # if surfaces: + # items.append(self.file.createIfcGeometricSet(surfaces)) return self.file.createIfcShapeRepresentation( self.settings["context"], self.settings["context"].ContextIdentifier,