diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index eb14ece33a..8e8435baed 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -91,6 +91,10 @@ class entity_instance(object): def __repr__(self): return repr(self.wrapped_data) def is_a(self, *args): return self.wrapped_data.is_a(*args) def id(self): return self.wrapped_data.id() + def __eq__(self, other): + return self.wrapped_data == other.wrapped_data + def __hash__(self): + return hash((self.id(), self.wrapped_data.file_pointer())) def __dir__(self): return sorted(set(itertools.chain( dir(type(self)), diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 23955f190f..24ace4cf10 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -124,6 +124,18 @@ namespace IfcUtil { unsigned i = IfcSchema::Type::GetAttributeIndex($self->type(), a); return std::pair($self->getArgumentType(i), $self->getArgument(i)); } + + bool __eq__(IfcParse::IfcLateBoundEntity* other) const { + if ($self == other) { + return true; + } + return $self->id() == other->id() && $self->entity->file == other->entity->file; + } + + // Just something to have a somewhat sensible value to hash + size_t file_pointer() const { + return reinterpret_cast($self->entity->file); + } } %extend IfcParse::IfcSpfHeader {