Rotating buildings to be parallel with road center line

I am modeling a city with .osm data and for some reason the houses/buildings are crooked (See Image). I am trying to fix this.

I was thinking that whatever building edge has the shortest distance to a centerline, you could rotate the building so that face is parallel with the referenced line. If the line was curved, it would reference the closest point on that curve.

I have create a rudimentary solution for one building with one line, but I was wondering if anyone would have a better solution for multiple building referencing multiple center lines (Image 2 is my attempt with the same script). I am not too good with the matching of data correctly but I know that there is something wrong in this regard with my script. And I also know that my choice of components isn’t the greatest given the logic I mentioned.

Thanks in advance!

Help Rotating (13.8 KB)

Help Rotating Buildings (14.8 KB)


That is the much better solution I was hoping for. Thank you!!!

You’re welcome.