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.
Exponential horn along spline or collection of edges
mathias_nielsen
Member Posts: 2 ✭✭
Hi.
I am trying to create a model of a back loaded horn speaker.
This basically means calculating a horn shape according to parameters for the speaker and then try to fold this horn in order for it to fit inside a reasonably sized box.
Traditionally this has meant producing cases looking like this:
But since more and more have access to CNC equipment (myself included) a new design have seen wider adoption in the later years:
This last one is what I am trying to do.
I have the calculations for the horn down, but it would be nice if I could make onshape do all the hard work by simply having it follow a single spline or a selection of edges and then drawing a line on each side that follows along, but at a distance that increases according to the formulae that I have.
I have tried looking at creating a new feature for this, but I am a little stuck as to which operation will helt me acheive what I want.
Neither sweep nor loft seems to be able to do what I want, even when used from a custom feature script, but I may be wrong.
I am trying to create a model of a back loaded horn speaker.
This basically means calculating a horn shape according to parameters for the speaker and then try to fold this horn in order for it to fit inside a reasonably sized box.
Traditionally this has meant producing cases looking like this:
But since more and more have access to CNC equipment (myself included) a new design have seen wider adoption in the later years:
This last one is what I am trying to do.
I have the calculations for the horn down, but it would be nice if I could make onshape do all the hard work by simply having it follow a single spline or a selection of edges and then drawing a line on each side that follows along, but at a distance that increases according to the formulae that I have.
I have tried looking at creating a new feature for this, but I am a little stuck as to which operation will helt me acheive what I want.
Neither sweep nor loft seems to be able to do what I want, even when used from a custom feature script, but I may be wrong.
Tagged:
0
Comments
Here's the type of thing:
https://cad.onshape.com/documents/fca50f3961de676b0120b395/w/e48c0296ca8911efccdddbe2/e/429fc52647065a78f3eb308e
I think I can even make it work for a selection of edges provided I remember correctly that there is a way to get the length of an edge even if it's a curve.
In any case, thank you very much for the input.
Yes, evLength will get you the edge length. The challenge with multiple edges is that they may be selected in arbitrary order and some may be flipped. The curve pattern example has some code for dealing with these issues.
Seems like there's a trivial solution to this problem.
Here's a curve:
Counting the inflections, you'll know the order of the curve, or in the cubic spline world the number of curve segments required. I wouldn't use arcs or lines make everything a spline possibly a multi-node spline.
Consider the entire length of path as 100%:
Step along your path at some increment and figure out which spline segment you're on top of. Take the 1st derivative of spline segment and compute tangent vector at the path increment (OS should provide this, haven't looked, but if not it's easy to compute if you know spline segment coefficients). Take triple product and get a normal direction from the tangent. Offset along the normal based on percent traveled and create a point in an array to be used later when creating a spline. Highlighted tangent vector on curve at a point:
Let's pretend your algorithm created all these points:
Create a spline using points in your array:
Obviously my exponential horn looks poor because I eyeballed in the node placement for the fit spline. I also only went half way. I guess I'm representing an exponential horn featurescript that needs debugging.
My original thought was to have the normal offset be linearly proportional to the traveled length, but there's no reason why you couldn't make it exponential x^2. Give you what you asked for.
Also, after it's up and running. I'd keep the last tangential vector in a variable and dot it with the newly computed one keeping track of the angle between them. As the angle increases (meaning you are changing curvature) decrease your increment value to give you greater resolution as your exponential curve is being created around curvature and when it straightens out use fewer points.
This would be a fun featurescript to play around with. Not sure about it's applications other than creating a bass port for your speaker.
Could featurescript do this? I haven't researched it. Should be able to since this is trivial CAD. I'd look for tangent vector to curve in the library. Should be in there. Use their functions in OS when possible as they'll be faster than any interpolated algorithm you write in featurescript.
I'd write this in 3D even though my path curve is 2D. 3D is just another term in the equations and would make your script more versatile. Follow an edge? Sure why not. If you've ever done this, you'll know picking the reference for your triple product becomes problematic. These guys do a good job at these strategies but they won't a share. This is where the math turns into art.
As always, when you finish it please share I'd like to see it.