You can now add IFC subdocuments or supersede documents

This commit is contained in:
Dion Moult
2022-03-15 14:41:47 +11:00
parent 9cc683ea6e
commit 6fb1e34ab4
2 changed files with 27 additions and 3 deletions
@@ -29,12 +29,12 @@ class Usecase:
def execute(self):
id_attribute = "DocumentId" if self.file.schema == "IFC2X3" else "Identification"
information = self.file.create_entity(
"IfcDocumentInformation", **{id_attribute: ifcopenshell.guid.new(), "Name": "Unnamed"}
"IfcDocumentInformation", **{id_attribute: "X", "Name": "Unnamed"}
)
parent = self.settings["parent"]
if not parent and self.file.by_type("IfcProject"):
parent = self.file.by_type("IfcProject")[0]
if parent.is_a("IfcProject") or prarent.is_a("IfcContext"):
if parent.is_a("IfcProject") or parent.is_a("IfcContext"):
self.file.create_entity(
"IfcRelAssociatesDocument",
GlobalId=ifcopenshell.guid.new(),
@@ -42,4 +42,16 @@ class Usecase:
RelatingDocument=information,
RelatedObjects=[parent],
)
elif parent.is_a("IfcDocumentInformation"):
if parent.IsPointer:
rel = parent.IsPointer[0]
documents = set(rel.RelatedDocuments)
documents.add(information)
rel.RelatedDocuments = list(documents)
else:
self.file.create_entity(
"IfcDocumentInformationRelationship",
RelatingDocument=parent,
RelatedDocuments=[information]
)
return information