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.
Distribution of points along spline
Rootentity
Member Posts: 21 ✭✭
I'm am making a featurescript to help with making horn loundspeaker ports. I've found a couple of threads that have asked about this kind of feature. I've made a lot of progress today. It mostly works now for constant angle expansion.
Link to script: SplineExpansion
The script makes points offset by a constant angle from a spline in a sketch. The idea is to do this on both sides and run new splines though all the points. The problem is that the points are evenly distributed around the original spline then offset on a perpendicular vector, Because of this the points spread apart around outside curves and more problematically bunch together on inside curves, greatly reducing how sharp a curve can be.
Is there a better technique than using perpendicular vectors, Or should I try to fix the distribution after they are offset? What would be the best way to deal with this problem?
Link to script: SplineExpansion
The script makes points offset by a constant angle from a spline in a sketch. The idea is to do this on both sides and run new splines though all the points. The problem is that the points are evenly distributed around the original spline then offset on a perpendicular vector, Because of this the points spread apart around outside curves and more problematically bunch together on inside curves, greatly reducing how sharp a curve can be.
Is there a better technique than using perpendicular vectors, Or should I try to fix the distribution after they are offset? What would be the best way to deal with this problem?
0
Best Answer

konstantin_shiriazdanov Posts: 941 ✭✭✭✭✭anyway here is example of that approach, now it has a constant offset along the spline, but you can add your function distance(l)
https://cad.onshape.com/documents/59007ff281e43510ea3797a2/w/a6cb15bca8f1b2bf6e312ccd/e/8695694c2f658a05d1fb7da2
by the way  the condition for offset spline inflecting itself is offset>curvature_radius_of_original_spline
5
Answers
evEdgeCurvature().frame.origin + curvatureFrameNormal(evEdgeCurvature())*distance(l), where distance(l) is the userdefined law of distance variation along the length of the spline. and when you obtained 3d coordinate of the point you can even move it the original spline plane coordinate system using worldToPlane()
https://cad.onshape.com/documents/59007ff281e43510ea3797a2/w/a6cb15bca8f1b2bf6e312ccd/e/8695694c2f658a05d1fb7da2
by the way  the condition for offset spline inflecting itself is offset>curvature_radius_of_original_spline
Can't you offset curve in API? Then create a new points along this offset curve?
I just checked API for offset curve and didn't find it.
I did find:
create surface from curve
offset surface
project curve (offset surface & plane curve was defined on)
This would give you an offset curve relative to your original curve.
Then you could dance through the offset curve setting points.
Off course you'd have to throw an error when parasolid's returns a cusp. I have never seen a surface cusp in SW or OS. Someone blocks it.
I wrote a spline generator that put points along a spline based on cordial height. As the curvature tightened up, I'd place more points for the new curve. Kinda of a fit spline approach. Infact, I think it's called 'fit spline' and it's in the public domain.
I had issues with spline direction as sometimes I needed to go from 0 > 1 and then sometimes 1>0. I have 5 lines of code to decide the direction but it didn't work all the time.
You could create curves on the top plane, then create curves on the antitop and then try to fit a spline through all these curves. My 5 lines of direction code fell apart and I realized how hard it is to write robust CAD code.