Create interior walls from cad link

Hey guys,
I’m trying to use @Alban_de_Chasteigner solution for a more complex double lines of walls. In the solution he chooses longest line for the group of parallel lines in a margin. As you can see in my example, longest line is not the best here.

Walls from line on CAD insert.dyn (35.1 KB)
Create walls from Cad link lines

You can check the below link

Thanks for replying;
nope, I tried the script but it’s not working in my case, because it chooses longest line as wall exterior face… as you can see in my case longest is not the solution.