Creating rectangles from corner points and sorting by text

Greetings, guys

I’m totally new at Grasshopper and I don’t have any idea of coding - a lack of my studies here in Brazil (the country, not the plugin lol). I hope I can learn it now. But, for now, I need help. My problem is divided into two parts, if you can help with only one, I’m very grateful already.

FIRST PART: CREATING THE RECTANGLES AND GROUPS

What I’m trying to do is: I have some texts titles (YELLOW), coming along with some geometry (CYAN and RED for block instances), all only 2D geometry. First of all, I want to create rectangles that are the boundaries for those texts plus the geometry inside it (MAGENTA RECTANGLES). Each object has its own layer. See this GIF, this shows what I want to do automatically, through Grasshopper:

All I could do until now through Grasshopper is finding these corner points that I want to the rectangle starts. The rectangle must end at the intersection of the next rectangle, as you could see in the gif.

After that, I want that rectangle and all geometry inside becomes a group.

SECOND PART: SORTING AND POSITIONING

For finishing, I want to order those groups alphabetically, based in the text title, ordering retangle beside rectangle, in a row. This last part is a little hard, because of the syntax of the title, but I think that it can be ordered like this (i made up those examples):

VB2 [P1 - P2]
VB2 [(P3 - E5) - P4]
VB2 [(P6 - P5]
VB2 [(P6 - P7) - P3]
VB2 [P7 - P8]

So, the order is based on the first number after the VB2 prefix ( in this example, 1, 3, 6, 6, 7…)

I found some gh files that helped to extract the text, but nothing more than that.

I’m sorry to ask that much, but it’s all this newbie can do now. The example file is attached down there, if you want to see what I did until now. I’m ashamed that is a mess, but… it can help you understand.

Best regards,

Kevin

sorting example.3dm (203.6 KB)
sorting example.gh (16.9 KB)

grouped alphabetically, ordered rectangle in a row…

requires Elefront plugin.

The rectangles are approximate, if you want specific i would bake and stretch in rhino, then reference back into the script. This should give you some idea of possible workflows.

re sorting example.gh (16.4 KB)

Oh my, I can’t believe that you solved, and so fast. I coudn’t be more grateful.

Thank you a lot, Rickson.