Two Breps won't join

Hi, I am trying to troubleshoot why these two Breps won’t join:

The surfaces are separated at the red dashed line.

The upper surface is extruded out of the upper profile so it should definitely be coincident with the edge. Ultimately I need to get these to join so I can cap it.

Internalized script attached. Thanks for any assistance. (16.5 KB)

i get some revit level picker error on open

but besides that it seems that either you are picking the wrong cherries here, and/or you need the flatten on the brep join because of path mismatch

path mismatch.