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.

This commit is contained in:
Dion Moult
2023-03-20 16:36:38 +11:00
parent 65caa7906d
commit c97e1079e8
4 changed files with 18 additions and 9 deletions
+2 -2
View File
@@ -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)
+4 -1
View File
@@ -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)
+4
View File
@@ -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):
@@ -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,