mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
drawing.get_sheet_identification
This commit is contained in:
@@ -493,8 +493,11 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ensure_unique_identification(cls, identification: str) -> str:
|
def ensure_unique_identification(cls, identification: str) -> str:
|
||||||
attr = "DocumentId" if tool.Ifc.get_schema() == "IFC2X3" else "Identification"
|
ids = [
|
||||||
ids = [getattr(d, attr) for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
|
cls.get_sheet_identification(d)
|
||||||
|
for d in tool.Ifc.get().by_type("IfcDocumentInformation")
|
||||||
|
if d.Scope == "SHEET"
|
||||||
|
]
|
||||||
while identification in ids:
|
while identification in ids:
|
||||||
identification += "-X"
|
identification += "-X"
|
||||||
return identification
|
return identification
|
||||||
@@ -985,6 +988,12 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
else:
|
else:
|
||||||
new.identification = schedule.Identification
|
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
|
@classmethod
|
||||||
def import_sheets(cls) -> None:
|
def import_sheets(cls) -> None:
|
||||||
props = cls.get_document_props()
|
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})
|
cls.sheet_selected_states.update({s.ifc_definition_id: s.is_selected for s in props.sheets if s.is_sheet})
|
||||||
props.sheets.clear()
|
props.sheets.clear()
|
||||||
sheets = [d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
|
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 = props.sheets.add()
|
||||||
new.ifc_definition_id = sheet.id()
|
new.ifc_definition_id = sheet.id()
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
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)
|
ifc_file_dir = os.path.dirname(props.ifc_file)
|
||||||
|
|
||||||
sheets = [d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SHEET"]
|
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):
|
for reference in tool.Drawing.get_document_references(sheet):
|
||||||
reference_description = tool.Drawing.get_reference_description(reference)
|
reference_description = tool.Drawing.get_reference_description(reference)
|
||||||
if reference_description != "SHEET":
|
if reference_description != "SHEET":
|
||||||
|
|||||||
Reference in New Issue
Block a user