Connect land register file TEXT 2 POLYLINE (Kataster)

I have a file with Text and single polylines in dwg. I would like to identify the lines surronding the text and combine them to one closed polyline and give them the value of the Text. By change any idea how to solve?

For example this field (844) is surronded by 5 lines. Select these line and connect them to a closed polyline or hatch/area/whatever and give it the attribut 844.

Hi, you could use the revit algorithm to generate the rooms automatically
recovery of all curves (then transformed into rooms limits)

Hoping the text isn’t vectorized too

Sincerely
christian.stan