Creating Bridge modelling package - Problem connecting segments

Hello guys,
So I was trying to recreate Dynabridge package I have seen on YT, which has some issues currently. I have almost accomplished it, however, it seems a little bit off. The problem is that bridge body doesn’t seem to trace the coordinate points smoothly, which can be seen in below pic. Also, depending on the grid number or segment length adjusted XY plane of adaptive component sometimes is not right. I believe that there is coding issue, which I have marked with blue circle in the pic.

I would really appreciate any help cuz if it will be finished i am sure many people will use it. I will attach the code and all necessary components to run it on your computers if you want. Here is how to run it:

  1. After opening new project on REVIT change project unit - length into meters.
  2. Freeze Grid.Curve node in Local Coordiante System by grids group and then Run the code.
  3. In REVIT divide the path into segments by using grids.
  4. Select the grids by using Select Model elements node and unfreeze step 2.
  5. Run the code.

Below are all the attachments need to run the code and simulate my issue:
Bridge Adaptive 3 points type A.rfa (976 KB)
3d line.rfa (356 KB)
AlignmentVer1.xlsx (11.2 KB)
Dynabridge manually_Bridge Body.dyn (171.0 KB)

About adaptive component - It has 3 points. Start, mid, end point. And each segment of it is connected by adjusting XY plane of ending of the former segment and starting of the latter segment

What I think you can do is calculate the angle from curve normal vector to the axis of element, and then create this angle as a parameter.

Hope this works is you are still working on the same.