intersect bsplinesurface and line [solved]

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

intersect bsplinesurface and line [solved]

Post by sliptonic »

I have a bsplinesurface that I've constructed from a set of points. I also have a point inside the XY bounds of the surface and I want to find the corresponding Z coordinate on the surface.

If I construct a line that runs through X,Y,0 and X,Y,1, Can I find where that line intersects the surface?
Last edited by sliptonic on Wed Sep 19, 2018 6:08 pm, edited 1 time in total.
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: intersect bsplinesurface and line

Post by Chris_G »

Something like this ? :

Code: Select all

bs = Part.BSplineSurface()
pt = FreeCAD.Vector(0.2,0.6,100.)

vertical_line = Part.Line(pt, pt+FreeCAD.Vector(0,0,1))
# intersectCS() : Returns all intersection points and curve segments between the curve and the surface.
points, curves = vertical_line.intersectCS(bs)
points
# [<Point (0.2,0.6,0) >]
curves
# []
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: intersect bsplinesurface and line

Post by sliptonic »

Exactly like that. Thanks Chris_G.
Post Reply