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

Discussion in 'SolidWorks' started by james, Aug 16, 2005.

  1. james

    james Guest

    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.

    Please help prove me wrong! I want to type in equations for a
    line/curve!
     
    james, Aug 16, 2005
    #1
  2. james

    matt Guest

    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.


    http://mysite.verizon.net/mjlombard/

    Go to the macro library link, it's called eqcurve. Requires excel.

    Matt
     
    matt, Aug 16, 2005
    #2
  3. james

    TOP Guest

    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.
     
    TOP, Aug 16, 2005
    #3
  4. james

    sjm1.pitt Guest

    ....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
     
    sjm1.pitt, Aug 16, 2005
    #4
  5. james

    That70sTick Guest

    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).
     
    That70sTick, Aug 16, 2005
    #5
  6. james

    MM Guest

    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
     
    MM, Aug 16, 2005
    #6
  7. james

    sjm1.pitt Guest

    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
     
    sjm1.pitt, Aug 17, 2005
    #7
  8. james

    sjm1.pitt Guest

    interesting (duh)
     
    sjm1.pitt, Aug 17, 2005
    #8
  9. james

    sjm1.pitt Guest

    interesting (duh)
     
    sjm1.pitt, Aug 17, 2005
    #9
  10. james

    james Guest

    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!!!
     
    james, Aug 17, 2005
    #10
  11. james

    sjm1.pitt Guest

    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 <0.000014 in a few spots.
    For accurate optics this difference would be noticeable, but for the
    flashlight reflector, I'm not going to worry about.

    If anyone wants the report email me and I'll send the .pdf report, 1.3
    meg file zipped.

    Thanks again,

    sjm1
     
    sjm1.pitt, Sep 4, 2005
    #11
  12. james

    That70sTick Guest

    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.
     
    That70sTick, Sep 5, 2005
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.