U V parameterisation of surface do not change when preforming BooleanIntersection

The algorithme that I am trying to get to work, looks like this.
Find the intersection between a box and a Borders of a surface, and discretiza the intersection
But the U,V parameter after preforming a BooleanIntersection and a ExplodePolysurfaces is still linked to the original surface, so a discretization is conducted on the original surface not the intersection(Se the algorithm below or
before.3dm (22.8 KB)
after.3dm (491.6 KB)

Observe how the intercection between the surface and the box are there but eh points are from the original surface

import rhinoscriptsyntax as rs
import random
surface = rs.GetObject("Pick a surfacs")
box = rs.GetObject("Pick a box")

tmp = rs.BooleanIntersection(surface, box, False)

exp = rs.ExplodePolysurfaces(tmp)
for e in exp:
    u0, u1 = rs.SurfaceDomain(e, 0)
    v0, v1 = rs.SurfaceDomain(e, 1)
    up = random.uniform(u0, u1)
    vp = random.uniform(v0, v1)
    if rs.IsPointOnSurface(surface, rs.SurfaceEvaluate(e, [up, vp], 1)[0]):
        uDt = (u1 - u0)/float(50)
        vDt = (v1 - v0)/float(50)
        for u in range(0, 50):
            for v in range(0, 50):
                rs.AddPoint(rs.EvaluateSurface(e, u*uDt+u0, v*vDt+v0))


Boolean operations do not change the underlying surface. They calculate intersections and define new bounding conditions to define the polysurface.
Try to shrink the surfaces after boolean. Maybe that will help.

Thanks for the help, it did not work 100 % but got me closer.
By adding rs.ShrinkTrimmedSurface(tmp) in line 8 gave the following result

But by adding a check if rs.IsPointOnSurface(e, pnt): in line 22 gave me the correct result.

This is still a slow approach and would like a better solution, but it works for now.
The final code can be seen in result.py (879 Bytes)