Need guidance on data trees

Hi people,
My goal was to create frames for (model) aircraft canopies, the process I intended was to select one canopy surface (I have a layer specifically for that) and the script would find all surfaces in that layer (using eleFront) and I have made a sub-layer called ‘GH’ which holds curves that will define the frames: this sub-folder also might include ‘helper’ lines that are Projected (in Rhino) onto the surfaces to create the frame lines.
Thus my script uses MidPoint and SurfaceCompare to find the right curves, and then a SurfaceCompare at the start of those curves to get a Surface Normal to create a Sweep shape - but then it all goes wrong!
I obviously have a problem keeping the tree branches straight. The example grab shows one correct Sweep but the others are chaotic. Note that I internalised the relevant items but needed to Invert the Curve stream to get a result.
The ‘Select item in tree’ group is for my own visualisation.

Elefront Layer (298.0 KB)

Hi Quan Li, I know the surfaces and lines are separate - at this point that’s by design. I’m (hopefully) treating each surface separately and only looking at the curves on that surface. Each curve will have only one surface but each surface can have any number of curves.

Elefront Layer control_Internalised (299.4 KB)

I rebuilt and matched the surfaces, if you need.
Elefront Layer control_Internalised (399.9 KB)

Thanks Quan Li but I think there is a misunderstanding. I’m not trying to get the canopy but the frame.
This might illustrate:
I’m creating a basic canopy (transparent part) in Rhino then creating curves where I want the frame (the solid part that on a real aircraft holds the transparent panels together) to go. On older aircraft the frame can be noticable, which is why I’m trying to 1_Rail_Sweep a Rectangle along the curves.

Elefront Layer control_Internalised (327.0 KB)
Try V2.

Now you got it! I’m going to dive in and learn this lesson!
Thanks Quan Li!