Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
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
-
GregBrown Member, Onshape Employees, csevp Posts: 228
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:
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.