[io] correctly initialize the object counter if the hdf5 file contains already some objects
@@ -596,6 +596,13 @@ class MechanicsHdf5(object):
self._input = group(self._data, 'input')
+ # if the hdf5 file contains already some objects, we correcly initialize
+ # the object counter
+ if len(self._input) >= 0:
+ type_obj = [obj.attrs['type'] for (name, obj) in self._input.items()]
+ self._number_of_dynamic_objects = type_obj.count('dynamic')
+ self._number_of_static_objects = type_obj.count('static')
+
self._nslaws_data = group(self._data, 'nslaws')
return self
