mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
You can now add IFC subdocuments or supersede documents
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user