drawing.get_sheet_identification

This commit is contained in:
Andrej730
2025-07-07 14:04:05 +05:00
parent 1445f91289
commit d7668c3e3f
2 changed files with 13 additions and 4 deletions
+12 -3
View File
@@ -493,8 +493,11 @@ class Drawing(bonsai.core.tool.Drawing):
@classmethod
def ensure_unique_identification(cls, identification: str) -> str:
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"]
ids = [
cls.get_sheet_identification(d)
for d in tool.Ifc.get().by_type("IfcDocumentInformation")
if d.Scope == "SHEET"
]
while identification in ids:
identification += "-X"
return identification
@@ -985,6 +988,12 @@ class Drawing(bonsai.core.tool.Drawing):
else:
new.identification = schedule.Identification
@classmethod
def get_sheet_identification(cls, sheet: ifcopenshell.entity_instance) -> str:
"""Schema agnostic method to get IfcDocumentInformation.Identification."""
attr = "DocumentId" if sheet.file.schema == "IFC2X3" else "Identification"
return getattr(sheet, attr)
@classmethod
def import_sheets(cls) -> None:
props = cls.get_document_props()
@@ -994,7 +1003,7 @@ class Drawing(bonsai.core.tool.Drawing):
cls.sheet_selected_states.update({s.ifc_definition_id: s.is_selected for s in props.sheets if s.is_sheet})
props.sheets.clear()
sheets = [d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
for sheet in sorted(sheets, key=lambda s: getattr(s, "Identification", getattr(s, "DocumentId", None))):
for sheet in sorted(sheets, key=lambda s: cls.get_sheet_identification(s)):
new = props.sheets.add()
new.ifc_definition_id = sheet.id()
if tool.Ifc.get_schema() == "IFC2X3":
+1 -1
View File
@@ -741,7 +741,7 @@ class Web(bonsai.core.tool.Web):
ifc_file_dir = os.path.dirname(props.ifc_file)
sheets = [d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
for sheet in sorted(sheets, key=lambda s: getattr(s, "Identification", getattr(s, "DocumentId", None))):
for sheet in sorted(sheets, key=lambda s: tool.Drawing.get_sheet_identification(s)):
for reference in tool.Drawing.get_document_references(sheet):
reference_description = tool.Drawing.get_reference_description(reference)
if reference_description != "SHEET":