diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 658e01d80a..35e40598a8 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -80,6 +80,8 @@ class entity_instance(object): self[self.wrapped_data.get_argument_index(key)] = value def __getitem__(self, key): + if key < 0 or key >= len(self): + raise IndexError("Attribute index {} out of range for instance of type {}".format(key, self.is_a())) return entity_instance.wrap_value(self.wrapped_data.get_argument(key)) def __setitem__(self, idx, value):