Prevent overlapping between the squers during the generation

Hello all, and I thank everyone who helped me in the previous times. My question is how can we put a constraint to prevent overlapping between the squers during the generation. Some hints IF possible.The work is shown in the picture below

there are many ways. one way is reduce the distance you are using to make the rectangles, this distance can be 1/2 the distance between the centroids of the rectangles. to prevent overlap, use only the y part of the distance

Thank you very much. I was just thinking of having components to help with this, because the original layout I work on contains many surfaces. In case of increasing the space of one of them I work to reduce the other to avoid interference as in the following example