Create rectangular bounding box perpendicular to longer side

How can I make rectangle bounding box perpendicular to surface longer side?

Something like this: bound.gh (6.5 KB)

20_11_27_bbox_align_longest_edge.gh (17.1 KB)

Hi. I do try to adapt this script to my needs but seems that I do face some issues and I don’t know how to solve-it.

BBox_Perp_to_LongestSide_error.gh (27.8 KB)

The error says ‘1. Data conversion failed from Curve to Vector’

You need to rebuild the edges so they only consist of two points and can be interpreted as vectors.

BBox_Perp_to_LongestSide_error.gh (33.5 KB)

Thank you for the solution. Much better.