diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index b5b9ae7d6d..5fcaa92d4a 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -106,14 +106,17 @@ class AddAnnotationType(bpy.types.Operator, tool.Ifc.Operator): obj = bpy.data.objects.new(object_type, None) obj.name = props.type_name + ifc_context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Annotation", "MODEL_VIEW") element = tool.Drawing.run_root_assign_class( obj=obj, ifc_class="IfcTypeProduct", predefined_type=object_type, should_add_representation=has_representation, - context=ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Annotation", "MODEL_VIEW"), + context=ifc_context, ifc_representation_class=tool.Drawing.get_ifc_representation_class(object_type), ) + if representation := tool.Drawing.get_representation(element, ifc_context): + tool.Drawing.reload_representation(obj=obj, representation=representation) element.ApplicableOccurrence = f"IfcAnnotation/{object_type}" if props.create_representation_for_type and object_type == "IMAGE": diff --git a/src/bonsai/bonsai/core/drawing.py b/src/bonsai/bonsai/core/drawing.py index 2763f72ea0..cdf97a41fa 100644 --- a/src/bonsai/bonsai/core/drawing.py +++ b/src/bonsai/bonsai/core/drawing.py @@ -440,8 +440,7 @@ def add_annotation( drawing_tool.show_decorations() obj = drawing_tool.create_annotation_object(drawing, object_type) element = ifc.get_entity(obj) - # TODO: element is never None? - if not element: + if not element: # Brand new annotation relating_type_rep = drawing_tool.get_annotation_representation(relating_type) if relating_type else None element = drawing_tool.run_root_assign_class( obj=obj,