Allow user to toggle duplicates when getting inverses. See #1747.

This commit is contained in:
Dion Moult
2021-10-03 10:20:24 +11:00
parent 4697e063af
commit 6cc7d7963a
2 changed files with 11 additions and 3 deletions
+5 -2
View File
@@ -378,7 +378,7 @@ class file(object):
return [entity_instance(e, self) for e in fn(inst.wrapped_data, max_levels)]
def get_inverse(self, inst):
def get_inverse(self, inst, allow_duplicate=False):
"""Return a list of entities that reference this entity
:param inst: The entity instance to get inverse relationships
@@ -386,7 +386,10 @@ class file(object):
:returns: A list of ifcopenshell.entity_instance.entity_instance objects
:rtype: list
"""
return [entity_instance(e, self) for e in self.wrapped_data.get_inverse(inst.wrapped_data)]
inverses = [entity_instance(e, self) for e in self.wrapped_data.get_inverse(inst.wrapped_data)]
if allow_duplicate:
return inverses
return set(inverses)
def remove(self, inst):
"""Deletes an IFC object in the file.