How to arrange the buildings spacing automatically with dynamo?

Hello, everyone, I am from China.As an architect, I often meet the situation to arrange the buildings layout on the plot plan based on the fire safety national code. see diagram below.


the minimum distance is 6m between the buildings height no more than 24m.
the minimum distance is 13m between the buildings height more than 24m.
the minimum distance is 9m between one buildings height more than 24m and another is no more than 24m.

Currently I create different mass families to do the layout in Revit. can I promote the process by dynamo?

For example, Once I put in a mass family which is more than 24m ,the ambient mass families minimum distance less than 9 m could move automatically otherwise report an error.

Does anyone give me a clue for this solution?