document.import_references - note about not using Name #5542

This commit is contained in:
Andrej730
2024-10-14 14:57:02 +05:00
parent fac9444cfd
commit 16553417c1
+11 -16
View File
@@ -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: