A question about B-Spline to Interpolated-Spline
I’d like to ask if there is a way to convert a B-Spline (defined by control points, knots, etc.) into an Interpolated-Spline (defined solely by a series of points, similar to the spline in Onshape UI).
The evCurveDefinition function returns the parameters of the B-spline (control points, knots, etc.), but the parameters I originally provided are a series of points (interpolated spline). Is it possible to retrieve the original points in FeatureScript?
The JSON data of features obtained through the API seems to have "interpolationPoints," but their coordinates appear to be in a 2D local coordinate system, rather than the actual coordinates.
Definition of bspline:
Definition of interpolate spline:
Best Answer
-
What is the use case you are intending here?
You could approximate a given bspline at degree 3 (which is what interpolated curves are) then extract the position of the knots. This should get you pretty close to the locations of the "edit points" (as some systems call them) of an interpolated curve
Quick example in FeatureScript to approximate at deg=3 then get the knots:const e = evApproximateBSplineCurve(context, { "edge" : definition.edge, "forceCubic" : true, "forceNonRational" : true }); for (var i = 0; i < size(e.knots); i += 1) { const knotPos = evEdgeTangentLine(context, { "edge" : definition.edge, "parameter" : e.knots[i] }); debug(context, knotPos.origin, DebugColor.MAGENTA); }2
Answers
-
What is the use case you are intending here?
You could approximate a given bspline at degree 3 (which is what interpolated curves are) then extract the position of the knots. This should get you pretty close to the locations of the "edit points" (as some systems call them) of an interpolated curve
Quick example in FeatureScript to approximate at deg=3 then get the knots:const e = evApproximateBSplineCurve(context, { "edge" : definition.edge, "forceCubic" : true, "forceNonRational" : true }); for (var i = 0; i < size(e.knots); i += 1) { const knotPos = evEdgeTangentLine(context, { "edge" : definition.edge, "parameter" : e.knots[i] }); debug(context, knotPos.origin, DebugColor.MAGENTA); }2 -
Thank you, Greg, for your helpful answer.
The use case I have in mind is creating a custom feature that may allows further operations based on the (interpolated)points.
0

