mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
drawing.get_sheet_identification
This commit is contained in:
@@ -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":
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user