Hi caveman,
I don't really understand the problem.
If there are only 5 shapes like in your example, best would be to use proper snapping settings.
If there are a lot of shapes, where automation begins to make sense, then you would need to define more restrictions (same heigth and width? , how to define the central shape, ....)