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.
Linear interpolation in a Variable Table
pedro_restrepo
Member Posts: 7 ✭
I am new to Onshape and fairly new to CAD in general. I have two problems for which I have not found a solution after looking everywhere.
The first problems is this: can I define a new variable that uses a linear interpolation function such as lerp(a, b, f). a, b, and f are previously defined. Obviously, I don't quite understand the use of intrinsic functions. A workaround could be to define define the variable as #y1 + (#y2-#y1)/(#x2-#x1)*(#x-#x1), where #y1 is a, #y2 is b and f is (#x = #x1)/(#x2-#x1). So, for one interpolation, it's not too bad, but I need to do define a lot of interpolated variables. It's easy to make mistakes and takes a lot of typing.
The other problem I'd like to solve is how to define #x1 and #x2. I could use #XX1 =[10, 20, 30][#i1] and #XX2=[10, 20,30][#i2] , so if #i1 = 0, and #i2=1. #XX1=10, and #XX2 = 20. But that doubles the number of arrays. A two-dimensional array doesn't work: #XXX=[[10, 20, 30],[10, 20, 30]][#i1][#i2]] since #1 points at the row, and #i2 points at the column, which is the same. In procedural languages I can access any term of the array with a different index. However, Onshape ties the index to one specific variable, and I can't do something like XX1 = XXX[0][0] (10) and XX2=XXX[1][1] (20)
Answers
Maybe start with describing the problem you are trying to solve, rather than a specific technical approach. There are many ways to achieve many things - but some are better than others.
Onshape lets you upload CSV and JSON files to documents and retrieve data from those elements so at the very least you could look in to that approach.
@jnewth: Thank you for your suggestion. Here is my first problem:. Let's start with it.:
I have a model airplane wing that has three different cross sections: 1, at the root of the wing, 2 about 1/3 towards the tip, and 3, at the tip. The airfoil is similar but of different dimensions. I'd like to interpolate the dimensions of the wing sections located between the 1st and the 2nd known airfoils, and also for those between the 2nd and 3rd airfoils. A simple scale change wouldn't work, since there are elements that do not change regardless of the location. Also, the wing has what is known as a washout, where the angle of attack at the tip is smaller than at the front.
We can work on the second problem later.
Again, Thank you for your help
(apologies if you already know all this stuff, just beginning at the beginning)
Ok! I think I get it. What you are looking for is a Loft. https://cad.onshape.com/help/Content/PartStudio/loft.htm
You would create the different airfoils (as 2D sketches) on different planes. Then you would loft between these different profiles, creating a wing shape.
This will show you lots of things you can do with the Loft feature: https://www.onshape.com/en/resource-center/videos/loft-onshape-cad-tutorial
Be forewarned, the Loft feature is definitely not the simplest place to start with CAD. Have you tried going through some of the learning pathways? https://learn.onshape.com/
Onshape docs and tutorials are top-notch.
You might want to spend some time with these videos:
Simon Gatrall | Product Development, Engineering, Design, Onshape | Ex- IDEO, PCH, Unagi, Carbon | LinkedIn
@jnewth and @S1mon. I really appreciate the input. Thank you. I have used Loft already and thought it may help. I have the three wing ribs and am pretty sure I can get the loft. I am not sure how to get the cross sections to get the ribs. In other words: I need to cut the surface loft to arrive at the ribs and I'm not sure how to do that. I'll take a look at the videos.
Again, Thank you!
@S1mon, The videos actually help a lot! In my case (a P-51D model), the wing is a bit more complicated because there are about 4 "typical" cross sections and the wing has a washout which makes it impossible to use a plane like you use on the top plane to lay the root and tip ribs .I'll experiement with it. It'll be a great learning experience!