Inputting surface/spline functions? (SW 2007)
Inputting surface/spline functions? (SW 2007)
(OP)
I have recently acquired access to Solidworks 2007, and through a growing interest in fluid dynamics, I have realized that in aerospace engineering it can often be necessary to design fairly complex 3D surfaces, for example in designing airfoils and compressor blades.
CFD aside, suppose I were to crunch some numbers, and arrive at a mathematical function, f(x,y), describing a surface in 3D space. This surface would have been derived to be the most optimal surface to use for a compressor blade, under a certain set of fluid flow conditions.
Is it possible to input such mathematical functions into Solidworks (specifying the range of the function) to produce certain 'function-specific' surfaces or splines, for use with construction?
e.g. something like f(x,y) = sinx cosy (0<x<5,0<y<3), specifying a temporary axis, which the inequalities would refer to.
Thank you.
CFD aside, suppose I were to crunch some numbers, and arrive at a mathematical function, f(x,y), describing a surface in 3D space. This surface would have been derived to be the most optimal surface to use for a compressor blade, under a certain set of fluid flow conditions.
Is it possible to input such mathematical functions into Solidworks (specifying the range of the function) to produce certain 'function-specific' surfaces or splines, for use with construction?
e.g. something like f(x,y) = sinx cosy (0<x<5,0<y<3), specifying a temporary axis, which the inequalities would refer to.
Thank you.






RE: Inputting surface/spline functions? (SW 2007)
You may also be able to use the point import macro http://solidworks.cad.de/mm_24.htm to get the points into SW.
You would then need to use Insert > Curve > Through Reference Points with manually selected points to create profiles which in turn can be used to create a surface.
RE: Inputting surface/spline functions? (SW 2007)
According to the help file, you can import .txt files, as you say, and it also mentions the fact that you can create 3D curves in Microsoft Excel, save them as .txt files, and import them to Soldiworks.
So in Excel, I could have one column for x, another for y, and another for z. The y and x columns could increase at set increments (size depending on accuracy), and the z column would be given by, z=f(x,y), some function of x and y, whatever it be? Seems fairly straightforward, just have to make sure I get the format right when I save to excel.
Cheers!
RE: Inputting surface/spline functions? (SW 2007)
I think the reason is because in maths the graph of the function is drawn using ALL values of x and y, but of course, in solidworks it only uses those exact [x,y] co-ordinates I'm giving it.
Since Solidworks does not incorporate a direct function input, then it won't be possible to input functions directly for surfaces in 3D space. This means what I will have to do is to create two profiles on perpendicular planes, and compile them into a surface, where I can import data for each profile.
So, my next question is: how exactly do I create a surface out of two (perpendicular) planar profiles?
For example if one profile was in the top plane, and another in the front plane, then if you were to project each one into the screen, then the points where they coincide would make up the surface.
would I have to draw two sketches first, navigate to some 'surfaces' option, and select the two sketches to be used?
Cheers again!
RE: Inputting surface/spline functions? (SW 2007)
Were the calculated points supposed to describe a 3D surface?
Can you post an image (a hand drawn sketch would be fine) of what you are expecting the surface to look like?
Also, can you post either the .txt file or the SW file (or both) you created with the XYZ points?
RE: Inputting surface/spline functions? (SW 2007)
This graph is drawn for ALL values of x and y, (between -10 and 10, for each). The data I used is attached to this post. You can see that the x and y values increase by the same increment, and hence the spline I ended up with was actually the curve where the y=x plane intersects the paraboloid.
At the moment, I'm trying to import this surface into solidworks, mainly to get use to the method of importing functions (So that I can use it later on for more complex surfaces). It looks like the guy from the other thread managed to create the surfaces pretty well in his attempt.
I tried creating two separate profiles from this data. I put one on the XZ plane (setting y values to 0), and one on the YZ plane (setting x values to 0). I didn't have a clue what to do from there though.
The guy from the other thread seemed to do it fairly successfully, but it seems he used 3 different profiles for his blades. This makes me think I might need to make a third profile to create this surface too, but even then, I'm not sure what the next step is in compiling them together into a surface.
Thanks
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
The reason being is that some surfaces will be much more complex, such as compressor blades, where a simple circular revolve wouldn't work. In the other thread, he seemed to have three profiles, one on a top view, one on a side view, and one on a front view, and then used the 'boundary layer' function to make a surface between them.
Surely within that function, you would have to select the curves between which the surface is made, but actually the options are for 'direction 1', and 'direction 2'. I've had a mess around with it, and it seems If you create two 2d profiles on adjacent planes, then it will create a surface between them, as if the curves are mirrored on the opposite side of a parallelogram. So what if you wanted to create a triangular profile for example?
Also, when you thicken the surface, is there any options to add a differential to the thickness?...as opposed to having a constant thickness all along it.
Thanks
RE: Inputting surface/spline functions? (SW 2007)
No. The simplest way to create a varied thickness is to create another spline in the profile sketch which describes the thickness.
RE: Inputting surface/spline functions? (SW 2007)
I've attached the macro I wrote for creating 3D curves from parametric equations. It should make what you're trying to do a little quicker by cutting out text file generation step. Have fun.
RE: Inputting surface/spline functions? (SW 2007)
How would I go about creating such a set of parallel, equidistant planes, and select the distance between them? (I actually managed to do this before by accident, but undid it at the time, and now I can't remember how)
Also, once I have created a boundary surface, how would I go about filling it, to make it a solid entity? Can this still be done without being a completely closed volume?...I mean will it just create a simple boundary where there is none, before it fills?
Thanks again.
RE: Inputting surface/spline functions? (SW 2007)
So basically I can input a parametric equation to it, and it will create the text file for me?...or do you just import straight from the macro? Also what about specifying bounds? What about non-parameterized curves of the form z=f(x,y)?
Cheers!
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
It follows the equation format used by ProE. Each curve is entered with separate equations for each coordinate in Cartesion, cylindrical, or spherical coordinates. You can use any Excel function, and you will have to use T as a parameter in at least one coordinate equation.
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
Is there no way to enter z=x^2+y^2 directly, or does it all have to be done with the parameter T?
It looks pretty handy though, especially with the three co-ordinate systems. How can I get the button for it?
Thanks alot!
RE: Inputting surface/spline functions? (SW 2007)
Entering z = x^2 + y^2 is a surface function. The macro just plots curves. Your best bet for that particular function would be the plot a parabola using the equations below and then use the parabola to create a revolved surface rotated about the z axis.
X = 0
Y = A*%T (A is whatever the limit is for Y)
Z = %Y^2
RE: Inputting surface/spline functions? (SW 2007)
to get a crossection at the plane given by X = B
X = B
Y = A*%T
Z = %X^2 + %Y^2
Then just repeat at different values of B.
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
This is what I meant by a 'level set' of profiles. I understand setting a dimension (eg. X) constant to set a plane at that particular constant, and I'm also familiar with the form z=Ax^2+By^2 for an asymmetric paraboloid. Having opened up your surface, I can understand the setting of x, or y to equidistant constants, but the thing I don't understand is how you have use a parameterization with T in each curve. It seems to be done in such a way, that the set of 2D parabolas in one dimension, follow the set of parabolas in the other direction. Could you please elaborate on the functions you used? Thanks
RE: Inputting surface/spline functions? (SW 2007)
For example,
X = f(T) = f1(T)
Y = g(X) = g(f(T)) = f2(T)
Z = h(X,Y) = h(f1(T),f2(T)) = f3(T)
It all comes back to T in the end. T gives you the flexibility to have XYZ move independently of each other, but you can easily make them dependent, as shown in this example.
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
Ah, of course that really is incredibly helpful! So the 'X-set' of curves is just the surface function where the X-planes cross it (each at some constant value of X), and the 'Y-set' of curves is where the Y-planes cross the surface, when Y is set at some constant value. Thanks alot for the macro and the help...I can now do what I originally set out to do, without the added hassle of creating extra planes etc.
As for the bounds, A will set the upper bound, because when %T=1, A*%T = A?
So basically the process is:
Create 2 adjacent sets of planar profiles
For each curve:
-Set one variable constant (value of planar position)
-Set another to A*%T, to set the upper bound (and hence the domain where the function is evaluated)
-Set the final variable equal to the surface function, in terms of the other two variables.
Now would I be right in saying that it wouldn't matter what the surface function was, the above method will still work (providing smoothness?)? And that it doesn't matter which variable X, Y, or Z is assigned which step above, so long as no two are given the same step?...It seems reasonable that it should still work, but maybe I'm missing something?
Cheers!
RE: Inputting surface/spline functions? (SW 2007)
How can I set a lower bound for the function to be evaluated on? e.g. If I wanted a function evaluated between -5 and 5?
How can I get a shortcut button for the macro?
I inputted:
X=0
Y= (6*PI)*%T
Z=cos(%X)*cos(%Y)
...to evaluate z=cos(x)cos(y) on the plane x=0, between 0 and 6PI (3 repeats), and it didn't work. I got the message, "please correct the errors in Y". Is there something worng with my entering of PI? Can't this be entered as a known constant, or does it have to be entered manually? e.g. 3.14...?
Thanks
RE: Inputting surface/spline functions? (SW 2007)
RE: Inputting surface/spline functions? (SW 2007)
I'm glad you've got it working. Here are the answers to your questions.
Now would I be right in saying that it wouldn't matter what the surface function was, the above method will still work (providing smoothness?)?
Yes, as long as it is a well posed surface equation that can be evaluated by Excel as a function of the other two coordinates and T, it should work.
And that it doesn't matter which variable X, Y, or Z is assigned which step above, so long as no two are given the same step?
Yes, you can mix and match XYZ (or RThZ, RThPh).
How can I set a lower bound for the function to be evaluated on? e.g. If I wanted a function evaluated between -5 and 5?
Instead of using A*%T, use A*(%T-.5). I mentioned earlier in the thread that this yields a range of -A/2 to +A/2.
How can I get a shortcut button for the macro?
-With any file open, go to Tools>Customize.
-In the Commands tab, select Macros.
-Drag the New Macro button to any toolbar (it looks like a guy with a green shirt).
-Right-click the button you just placed.
-In the window that comes up, proceed to fill in Tooltip (macro name), Macro (location of the macro), Method (FuncPlot1.main).
-If you want a shortcut key, enter that as well. Also, any reasonably sized bitmap can be used as the button image.
-Click OK and you're done.
If you want a keyboard shortcut, but without a button:
-First, the SWP file must be in a directory identified in the system options as being a macro folder. To do this go to Tools>Options, System Options tab, File Locations page, Macros dropdown selection. Then add whatever location you want to use for macros. The default is C:\Program Files\SolidWorks\macros, but you can use any local or network location.
-Restart SW so it detects the macros the directory specified in the previous step.
-With any file open, go to Tools>Customize.
-Go to the Keyboard tab.
-Under the Macros heading you should see the macro name available to assign a shortcut.
Is there something worng with my entering of PI?
Actually, yes. Remember, the macro uses Excel for it's calculation engine. In Excel, Pi is treated like a function with no input parameters. You must use the syntax PI(). No parentheses, no go.
I hope this helps:)
RE: Inputting surface/spline functions? (SW 2007)
Got the shortcuts running, thanks for that.
"Instead of using A*%T, use A*(%T-.5). I mentioned earlier in the thread that this yields a range of -A/2 to +A/2."
Ok, thats simple enough. Any remedy for evaluating across something like -3, and 5, or 4 and 10?
For 4 and 10, maybe:
4+6*(%T) ?
and for -3 and 5, maybe:
-3+8*(%T) ?
That should work I think.
Also, I had a suggestion for you. After using the macro a little, I realized that the process could be quicker still if you could input:
1.) A set of constants B1, B2, B3... where each B sets the position of some plane. For example, instead of X=B, have X={B1,B2,B3...}. Basically, so you can create a set of planes/curves in one go, meaning you could do it once for X, once for Y, then create a boundary layer.
OR (for the same purpose)
2.) Set an upper and lower bound (for where you want the first plane to start, and the last to end), and tell it the number of planes you want to create, within those bounds. (Of course in this case, the planes would be equidistant).
I can't say I'm experienced with making API's, but from what programming I have done, I can't see it being that much harder to add these in. Of course, I'll let you be the judge of that, but I would love to see these functions added in. What d'ya reckon?
Cheers!
RE: Inputting surface/spline functions? (SW 2007)
http
(image was quite big to post)
Thanks
RE: Inputting surface/spline functions? (SW 2007)
Glad I could help
Any remedy for evaluating across something like -3, and 5, or 4 and 10?
Yes, what you have there should work fine. As a Generalization, your range should be set to A + (B-A)*%T, where A is the minimum value in your range, and B is the maximum.
The ability to input a set of constants B1, B2, B3 or an upper and lower bound
This is definitely possible, but it isn't a trivial feature to add. Currently the macro depends completely on Excel for parsing the equation strings. To do what you're asking would require that the macro detect when to override Excel's handling of equations, and parse certain types equation inputs differently. Either that or all the calculation must be enclosed in an additional loop that iterates over the various constants. To be honest, I probably would not put that much effort into it unless I was either being paid to do it, or it would save me a lot of time in my work. Since neither of those is true, the macro will likely stay the way it is. However, feel free to make modifications yourself, as long as I'm given credit for the original macro:)
when I have created a surface, or a set of surfaces/boundaries, then how can I make it into a solid?
I'm not a surfacing expert, but here are two of the simpler methods with which I'm familiar.
Insert>Boss/Base>Thicken
This will create a thick skinned version of your surface.
Insert>Surface>Knit
To do this you have to to create a closed volume using another surface. After trimming the extra portions of each surface, Knit will then attempt to merge the separate surfaces into a single solid body.
I've attached an example that creates a solid from an asymmetrical paraboloid surface and a flat surface. It also has a suppressed Thicken feature to show you the result of using that method as well.
Good luck
RE: Inputting surface/spline functions? (SW 2007)
http://members.cox.net/takedown/FuncPlot.zip
http://members.cox.net/takedown/SurfPlot.zip