diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 86113b9c95..eb51abfbd7 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -670,7 +670,19 @@ class Drawing(bonsai.core.tool.Drawing): @classmethod def get_body_context(cls) -> ifcopenshell.entity_instance: - return ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW") + context = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW") + if context: + return context + parent = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model") + if not parent: + parent = ifcopenshell.api.context.add_context(tool.Ifc.get(), context_type="Model") + return ifcopenshell.api.context.add_context( + tool.Ifc.get(), + context_type="Model", + context_identifier="Body", + target_view="MODEL_VIEW", + parent=parent, + ) @classmethod def get_document_uri(