Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:

  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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

RootentityRootentity 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?

Best Answer


  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 941 ✭✭✭✭✭
    edited April 2017
    if i'm not mistaken you need to create a pair of planar curves, that is distanced from the initial planar curve by some user-defined law. so i would propose to create those curves like 3d splines iterating along the spline edge and creating array of 3d points with coordinates, of the vector:
    evEdgeCurvature().frame.origin +
    curvatureFrameNormal(evEdgeCurvature())*distance(l), where distance(l) is the user-defined 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()
  • RootentityRootentity Member Posts: 21 ✭✭
    While I think that your solution is a cleaner more flexible example, and probably the correct way to proceed, It still suffers the bunching points problem.  I'm not sure that I'll be able to solve without resorting to some ugly calculus (probably over my head) to check if the offset spline inflects over itself.
  • billy2billy2 Member, OS Professional, Mentor, Developers Posts: 1,327 PRO
    edited April 2017

    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 anti-top 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.

  • RootentityRootentity Member Posts: 21 ✭✭
    anyway here is example of that approach, now it has a constant offset along the spline, but you can add your function distance(l)
    by the way - the condition for offset spline inflecting itself is offset>curvature_radius_of_original_spline
    Trying to wrap my head around all of this at once, and your coding circles around me, well 3d spirals actually.  Thank you for all of your help on this, what you have done so far seams really cool, and like it will be useful for quite a lot of things other than loudspeakers.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 941 ✭✭✭✭✭
    @Joshua_30 you asked an interesting challenge, and standart library turned out to have appropriate instruments)

Sign In or Register to comment.