Vectorising a grid of points to create 3D structure

Looking to produce a method for creating a structural grid that is constrained to the boundaries of a brep or other geometry. In this case I am trying to create a sphere but would like to translate to a variety of other forms. Where I am stuck is trying to vectorise the points whilst stopping at the edges in order to create curves for extrusion (see example image). This might not be the best approach so any advice would be greatly appreciated.

Many thanks,
Barney

example

Instead of separating the points using the brep, first convert the regular grid to vectors using the method in the attached image and then use ‘trim with breps’ component.