From 16553417c1df7f9035f689d8c8db7a46cee56066 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 14 Oct 2024 14:57:02 +0500 Subject: [PATCH] document.import_references - note about not using Name #5542 --- src/bonsai/bonsai/tool/document.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/bonsai/bonsai/tool/document.py b/src/bonsai/bonsai/tool/document.py index 4887e55e14..da04aa6e24 100644 --- a/src/bonsai/bonsai/tool/document.py +++ b/src/bonsai/bonsai/tool/document.py @@ -89,22 +89,17 @@ class Document(bonsai.core.tool.Document): @classmethod def import_references(cls, document: ifcopenshell.entity_instance) -> None: props = bpy.context.scene.BIMDocumentProperties - if tool.Ifc.get_schema() == "IFC2X3": - for element in document.DocumentReferences or []: - new = props.documents.add() - new.ifc_definition_id = element.id() - name = " - ".join([x for x in [element.Description, element.Location] if x]) - new.name = name or "Unnamed" - new.identification = element.ItemReference or "*" - new.is_information = False - else: - for element in document.HasDocumentReferences: - new = props.documents.add() - new.ifc_definition_id = element.id() - name = " - ".join([x for x in [element.Description, element.Location] if x]) - new.name = name or "Unnamed" - new.identification = element.Identification or "*" - new.is_information = False + is_ifc2x3 = tool.Ifc.get_schema() == "IFC2X3" + references = (document.DocumentReference or []) if is_ifc2x3 else document.HasDocumentReferences + for element in references: + new = props.documents.add() + new.ifc_definition_id = element.id() + # Use Description + Location instead of Name as IFC has a restriction + # for IfcDocumentReference to have Name only if it has no ReferencedDocument. + name = " - ".join([x for x in [element.Description, element.Location] if x]) + new.name = name or "Unnamed" + new.identification = (element.ItemReference if is_ifc2x3 else element.Identification) or "*" + new.is_information = False @classmethod def import_subdocuments(cls, document: ifcopenshell.entity_instance) -> None: