# Drawing a curve in a sketch using an equation - is it possible?

Someone I'm doing some work with on a project swears you can plot a
line in solidworks using an equation. (He's more of a ProE guy than a
solidworks guy - please don't throw stones my way...)
I have been doing some conic sections recently by actually sectioning a
cone, using "offset entities" to create a sketch of the conic section,
then chopping away the sectioned cone, leaving me with my sketch of a
hyperbola, parabola, etc.
Is there a way to type in equations for curves?
for example: y = x^2
or: y = sin(x)
or: y = mx + b
(in my 8 years of SW experience, I've never seen it).
I know you should never say never, but I just don't think it's
possible.
line/curve!
There's nothing built in to SW to do that, but I have a macro that will draw a spline for you based on an equation and some other input.
Go to the macro library link, it's called eqcurve. Requires excel.
Matt
Almost that simple.
If you want something like a spline on a sketch plane then record a macro. The macro will contain the creation of the sketch and the spline.
Delete the sketch used to create the macro and edit the macro. The basic idea is to create a FOR - NEXT loop that defines the spline. The one thing you have to watch out for is that the number of spline points used has to count down to 1. You create a parametric equation for x like:
x = A* sin(2*pi()*i/N)
where A and N are the amplitude and number of points to be plotted. Then A = 1 N = 20 FOR i = N to 1 step -1 x=2*pi()*i/N y=sin(x) code for creating a spline point with parameters i, x, y, 0 NEXT i
You will have to use your own analytic geometry skills to adjust the origin for the curve as well as how many cycles, etc.
However, now is a good time to ask that SW really get on the parametric bandwagon so that such an equation can be driven by distance along another curve like Pro/E.
...and Thank You Matt for the link to the macro! I used this a month or so ago and it worked great for the parabolic mirror I was working on.
Thank you again,
sjm1.pitt
I examined your macro, Matt. Overall, very nice. One more reason that I am a fan of your work.
SW sketches support parabolas. For this purpose (a parabolic mirror), a parabola in a sketch is going to be more accurate, especially if you need the optical properties. Interpolating a spline (like the macro does) is going to introduce slight errors due to the fact that SW splines are 2nd degree in X and Y. I have done some comparisons in the past laying splines over parabolas to see how close they are. The spline always has some error, no matter how well defined.
A true parabola can be fully defined by 3 points. From the parabola equation, it is possible to determine three points to fully define and sketch a parabola. In the case f a parabolic mirror, you probably want to control the focus and apex (which actually define w/ 2 points).
Paul.
Very good point.
It doesn't fit their "dumb everything down to the lowest common denominator" philosophy though. Don't hold your breath.
Mark
Thanks Tick, that is intresting. The mirror was for a flashlight prototype that was to be SLA'ed then a mirror plating applied.
I'll model the same mirror with the parabola sketch command and pop both models into GeoMagic Qualify and compare.
sjm1.pitt
interesting (duh)
interesting (duh)
Thanks for the info everyone.
For a "perfect" hyperbola, it looks like I'm still stuck with doing actual conic sections, then chopping away that's used to create it.
Thanks though! I'm sure I'll find some other uses for the spline macro. That's very cool!!!
Hi Tick,
I drew the mirror in SW using the parabola sketch tool. Then using GeoMagic Qualify 6, I compared the two models. There was a small difference between the two I examined your macro, Matt. Overall, very nice. One more reason that
I suppose I wouldn't sweat it too much over a flashlight. Wasn't trying to bee too nit-picky. Mostly I'm just a bit of a math geek, so I tend to dig deeper into how CAD programs process geometry.

#### Site Timeline

• Is anyone else having problems with external references and mates attached to...
• next in

• Hey All: I'll start by saying that I'm pretty familiar with solidworks custom...
• previous in

• I apparently saved a part in the rolled back state while working in an assembly....
• last updated in

• I am trying to create a boundary surface relation in SolidWorks, while selecting...
• last posted in