mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix support for document references in IFC2X3
This commit is contained in:
@@ -84,21 +84,28 @@ class ObjectDocumentData:
|
||||
continue
|
||||
|
||||
name = rel.RelatingDocument.Name
|
||||
if not name and rel.RelatingDocument.ReferencedDocument:
|
||||
name = rel.RelatingDocument.ReferencedDocument.Name
|
||||
|
||||
if tool.Ifc.get_schema() == "IFC2X3":
|
||||
if not name and rel.RelatingDocument.ReferenceToDocument:
|
||||
name = rel.RelatingDocument.ReferenceToDocument[0].Name
|
||||
|
||||
identification = rel.RelatingDocument.ItemReference
|
||||
if not identification and rel.RelatingDocument.ReferencedDocument:
|
||||
identification = rel.RelatingDocument.ReferencedDocument.DocumentId
|
||||
if not identification and rel.RelatingDocument.ReferenceToDocument:
|
||||
identification = rel.RelatingDocument.ReferenceToDocument[0].DocumentId
|
||||
|
||||
location = rel.RelatingDocument.Location
|
||||
else:
|
||||
if not name and rel.RelatingDocument.ReferencedDocument:
|
||||
name = rel.RelatingDocument.ReferencedDocument.Name
|
||||
|
||||
identification = rel.RelatingDocument.Identification
|
||||
if not identification and rel.RelatingDocument.ReferencedDocument:
|
||||
identification = rel.RelatingDocument.ReferencedDocument.Identification
|
||||
|
||||
location = rel.RelatingDocument.Location
|
||||
if location is None and rel.RelatingDocument.ReferencedDocument:
|
||||
location = rel.RelatingDocument.ReferencedDocument.Location
|
||||
location = rel.RelatingDocument.Location
|
||||
if location is None and rel.RelatingDocument.ReferencedDocument:
|
||||
location = rel.RelatingDocument.ReferencedDocument.Location
|
||||
|
||||
if location:
|
||||
if not "://" in location:
|
||||
if not os.path.isabs(location):
|
||||
|
||||
@@ -26,5 +26,10 @@ class Usecase:
|
||||
|
||||
def execute(self):
|
||||
if self.file.schema == "IFC2X3":
|
||||
return self.file.create_entity("IfcDocumentReference")
|
||||
reference = self.file.create_entity("IfcDocumentReference")
|
||||
if self.settings["information"]:
|
||||
references = list(self.settings["information"].DocumentReferences or [])
|
||||
references.append(reference)
|
||||
self.settings["information"].DocumentReferences = references
|
||||
return reference
|
||||
return self.file.create_entity("IfcDocumentReference", ReferencedDocument=self.settings["information"])
|
||||
|
||||
@@ -33,3 +33,18 @@ class TestAddReference(test.bootstrap.IFC4):
|
||||
assert element.is_a("IfcDocumentReference")
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 1
|
||||
assert element.ReferencedDocument == information
|
||||
|
||||
|
||||
class TestAddReferenceIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_adding_a_reference(self):
|
||||
element = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
assert element.is_a("IfcDocumentReference")
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 1
|
||||
|
||||
def test_adding_a_reference_to_an_information(self):
|
||||
self.file.createIfcProject()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
element = ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||
assert element.is_a("IfcDocumentReference")
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 1
|
||||
assert element.ReferenceToDocument[0] == information
|
||||
|
||||
Reference in New Issue
Block a user