mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
document.import_references - note about not using Name #5542
This commit is contained in:
@@ -89,22 +89,17 @@ class Document(bonsai.core.tool.Document):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def import_references(cls, document: ifcopenshell.entity_instance) -> None:
|
def import_references(cls, document: ifcopenshell.entity_instance) -> None:
|
||||||
props = bpy.context.scene.BIMDocumentProperties
|
props = bpy.context.scene.BIMDocumentProperties
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
is_ifc2x3 = tool.Ifc.get_schema() == "IFC2X3"
|
||||||
for element in document.DocumentReferences or []:
|
references = (document.DocumentReference or []) if is_ifc2x3 else document.HasDocumentReferences
|
||||||
new = props.documents.add()
|
for element in references:
|
||||||
new.ifc_definition_id = element.id()
|
new = props.documents.add()
|
||||||
name = " - ".join([x for x in [element.Description, element.Location] if x])
|
new.ifc_definition_id = element.id()
|
||||||
new.name = name or "Unnamed"
|
# Use Description + Location instead of Name as IFC has a restriction
|
||||||
new.identification = element.ItemReference or "*"
|
# for IfcDocumentReference to have Name only if it has no ReferencedDocument.
|
||||||
new.is_information = False
|
name = " - ".join([x for x in [element.Description, element.Location] if x])
|
||||||
else:
|
new.name = name or "Unnamed"
|
||||||
for element in document.HasDocumentReferences:
|
new.identification = (element.ItemReference if is_ifc2x3 else element.Identification) or "*"
|
||||||
new = props.documents.add()
|
new.is_information = False
|
||||||
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
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_subdocuments(cls, document: ifcopenshell.entity_instance) -> None:
|
def import_subdocuments(cls, document: ifcopenshell.entity_instance) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user