mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user