Fix new sheets having non-unique identification

It was checking for the wrong scope "DOCUMENTATION".
Scope "DOCUMENTATION" was left from the old times, now we use scope "SHEET".
This commit is contained in:
Andrej730
2024-09-02 16:46:50 +05:00
parent 7c542418e6
commit ccbb253d2c
2 changed files with 7 additions and 11 deletions
+3 -7
View File
@@ -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
+4 -4
View File
@@ -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"