diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index ce7e272b4d..c2377bc259 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -387,12 +387,8 @@ class Drawing(bonsai.core.tool.Drawing): @classmethod def ensure_unique_identification(cls, identification: str) -> str: - if tool.Ifc.get_schema() == "IFC2X3": - ids = [d.DocumentId for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION"] - else: - ids = [ - d.Identification for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION" - ] + attr = "DocumentId" if tool.Ifc.get_schema() == "IFC2X3" else "Identification" + ids = [getattr(d, attr) for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"] while identification in ids: identification += "-X" return identification @@ -568,7 +564,7 @@ class Drawing(bonsai.core.tool.Drawing): @classmethod def generate_sheet_identification(cls) -> str: - number = len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION"]) + number = len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]) return "A" + str(number).zfill(2) @classmethod diff --git a/src/bonsai/test/tool/test_drawing.py b/src/bonsai/test/tool/test_drawing.py index d4b392009e..241588cc3a 100644 --- a/src/bonsai/test/tool/test_drawing.py +++ b/src/bonsai/test/tool/test_drawing.py @@ -220,18 +220,18 @@ class TestEnsureUniqueIdentification(NewFile): ifc = ifcopenshell.file() tool.Ifc.set(ifc) assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR" - ifc.createIfcDocumentInformation(Identification="FOOBAR", Scope="DOCUMENTATION") + ifc.createIfcDocumentInformation(Identification="FOOBAR", Scope="SHEET") assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X" - ifc.createIfcDocumentInformation(Identification="FOOBAR-X", Scope="DOCUMENTATION") + ifc.createIfcDocumentInformation(Identification="FOOBAR-X", Scope="SHEET") assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X" def test_unique_document_id_ifc2x3(self): ifc = ifcopenshell.file(schema="IFC2X3") tool.Ifc.set(ifc) assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR" - ifc.createIfcDocumentInformation(DocumentId="FOOBAR", Scope="DOCUMENTATION") + ifc.createIfcDocumentInformation(DocumentId="FOOBAR", Scope="SHEET") assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X" - ifc.createIfcDocumentInformation(DocumentId="FOOBAR-X", Scope="DOCUMENTATION") + ifc.createIfcDocumentInformation(DocumentId="FOOBAR-X", Scope="SHEET") assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X"