×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Inputting surface/spline functions? (SW 2007)
2

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.

RE: Inputting surface/spline functions? (SW 2007)

Not directly, but if you can create a .txt format file, you can import that into SW. Check the SW Help-Index file for curves, through XYZ points.

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.

cheers

RE: Inputting surface/spline functions? (SW 2007)

(OP)
Thanks alot, thats a great help!

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)

(OP)
I managed to import some data from Excel. The function I used was z = x^2 + y^2, and when I imported it under 'insert>curve>curve through XYZ points', it gave me a 3D spline. From mathematics, I know that the function f(x,y) = x^2 + y^2 is actually a surface in 3D space, not just a simple spline.

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)

See thread559-184959: how to build compressor wheel from x,y,z coordinates for some similar info.

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?

cheers

RE: Inputting surface/spline functions? (SW 2007)

(OP)
The function of z=x^2+y^2 is actually a 'paraboloid' in 3D space, which is a surface that looks something like this:



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)

(OP)
Thanks alot thats just what i was trying to do. In the case of the function z=x^2+y^2, the intersection of an x-y plane, at any z, with the paraboloid is actually a circle, meaning it is possible to revolve the 2D profile into the surface of the paraboloid. I did think about using such a method, but didn't really look into it much.

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)

"when you thicken the surface, is there any options to add a differential to the thickness?"
No. The simplest way to create a varied thickness is to create another spline in the profile sketch which describes the thickness.

cheers

RE: Inputting surface/spline functions? (SW 2007)

(OP)
Thanks, I figured that might be the case. I thought about creating a 'level set' of the surface, which is basically a set of 2D cross-sectional profiles, each belonging to a plane, which are unit distance apart. Then I could use the boundary surface feature to make the surface.

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)

(OP)
Thanks 'takedownca', looks like you just beat me to the mark with that reply. Anyway, thanks for the macro, I'll give it a whirl at some point.

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)

(OP)
I opened the SWP file with sldworks, started a new part, went to insert>curves>curve through XYZ points, and The menu is still the same. Other than that what am I supposed to do with the file? Thanks

RE: Inputting surface/spline functions? (SW 2007)

Copy the SWP file to where your other macros are located.  If you don't have a location already, then put it in C:\Program Files\SolidWorks\macros. Then run the macro using Tools>Macro>Run. Select the macro and just follow the directions in the GUI. You don't have to use the Insert Curve function. The macro does it for you.

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)

I forgot, you can also make a button that runs the macro.

RE: Inputting surface/spline functions? (SW 2007)

(OP)
OK, thanks I got it working. So you have to express each dimension, X,Y,Z, in terms of a parameter T? And the functions are all Excel functions? For example POWER(base,power) ? I'm not familiar with ProE.

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)

Yes, enter the equations exactly as you would in Excel. So POWER(base,power) should work.  Although I would just use base^power. Also, any trig functions use radians (because Excel uses radians).  Just look at the example equations that come up when you first start the macro.

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)

I just reread the thread and realized you won't always be using a simple rotationally symmetrical surface.  For a more generalized case, you can create cross-sections at various plane offsets by plugging in different constants for X & Y that correspond to the cutting plane.  For example,

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)

One more thing.  You can change the Y equation to read Y = A*(%T - .5).  This will give you a symmetric function distribution from -.5A to +.5A, instead of 0 to A.

RE: Inputting surface/spline functions? (SW 2007)

(OP)
"you won't always be using a simple rotationally symmetrical surface.  For a more generalized case, you can create cross-sections at various plane offsets by plugging in different constants for X & Y that correspond to the cutting plane.  For example,"

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)

T is just a parameter that goes from 0 to 1 in increments of 1/(#Points - 1). so setting Y = A*%T just means I want Y to go from 0 to A.  You don't have to use T in every equation, but it needs to be in at least one of them in order to give the macro a range of values it iterate over.

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)

I think I understand your question now about the curves "following" each other. The parabolas intersect each other because the the equation for Z is the same between curves.  It was always Z = 2*%X^2 + %Y^2.  The different parabolas were generated by varying X & Y only.  In one direction, Y = %T - .5, but I used X = -.5, -.25, 0, .25, .5.  Similarly, in the other direction I set X = %T - .5 and Y = .5, .25, 0, -.25, -.5.  That's how I created the grid of of parabolic cross-sections.

RE: Inputting surface/spline functions? (SW 2007)

(OP)
"I think I understand your question now about the curves "following" each other. The parabolas intersect each other because the the equation for Z is the same between curves.  It was always Z = 2*%X^2 + %Y^2.  The different parabolas were generated by varying X & Y only.  In one direction, Y = %T - .5, but I used X = -.5, -.25, 0, .25, .5.  Similarly, in the other direction I set X = %T - .5 and Y = .5, .25, 0, -.25, -.5.  That's how I created the grid of of parabolic cross-sections."

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)

(OP)
Actually a couple more questions too:

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)

(OP)
...entering z= (6*3.14159265)*%T worked, so I guess it must be a problem with pi.

RE: Inputting surface/spline functions? (SW 2007)

Nabla,
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)

(OP)
Thanks again. So with PI all I'm missing is the parentheses then.

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)

(OP)
Sorry to keep asking questions, but I want to know, when I have created a surface, or a set of surfaces/boundaries, then how can I make it into a solid? (i.e. 'fill' it), for example something like this:

http://img528.imageshack.us/img528/880/cosxcocyff2.jpg

(image was quite big to post)

Thanks

RE: Inputting surface/spline functions? (SW 2007)

Nabla,
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)

Although I said I wouldn't be adding to my macro the ability to plot multiple curve sets, I ended up doing it anyway for fun. I also added surface creation.  Below are the two macros - FuncPlot creates 3D curves, SurfPlot creates 3D surfaces or curve sets/grids.  Currently, implicit functions (f(x,y,z)=0) are not supported.  Also, the surfaces and curves must be something producible in SW. Curves can't intersect themselves, and surfaces must be something constructable via boundary surface.  The concept of using Excel for calculation was gleaned from Matt Lombard's eqcurve macro.  I hope somebody finds these useful or at least educational.

http://members.cox.net/takedown/FuncPlot.zip
http://members.cox.net/takedown/SurfPlot.zip

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources