mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +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
|
@classmethod
|
||||||
def ensure_unique_identification(cls, identification: str) -> str:
|
def ensure_unique_identification(cls, identification: str) -> str:
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
attr = "DocumentId" if tool.Ifc.get_schema() == "IFC2X3" else "Identification"
|
||||||
ids = [d.DocumentId for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION"]
|
ids = [getattr(d, attr) for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
|
||||||
else:
|
|
||||||
ids = [
|
|
||||||
d.Identification for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "DOCUMENTATION"
|
|
||||||
]
|
|
||||||
while identification in ids:
|
while identification in ids:
|
||||||
identification += "-X"
|
identification += "-X"
|
||||||
return identification
|
return identification
|
||||||
@@ -568,7 +564,7 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_sheet_identification(cls) -> str:
|
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)
|
return "A" + str(number).zfill(2)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -220,18 +220,18 @@ class TestEnsureUniqueIdentification(NewFile):
|
|||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
tool.Ifc.set(ifc)
|
tool.Ifc.set(ifc)
|
||||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR"
|
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"
|
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"
|
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X"
|
||||||
|
|
||||||
def test_unique_document_id_ifc2x3(self):
|
def test_unique_document_id_ifc2x3(self):
|
||||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||||
tool.Ifc.set(ifc)
|
tool.Ifc.set(ifc)
|
||||||
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR"
|
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"
|
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"
|
assert subject.ensure_unique_identification("FOOBAR") == "FOOBAR-X-X"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user