Mathematical functions for curves in sketch

Discussion in 'SolidWorks' started by strela, Dec 24, 2007.

  1. strela

    strela Guest

    Is there a way to use mathematical functions for curves used in sketch to
    describe cross section of a part? For example, square without one straight
    edge (eg. top one), but curve that would have some mathematical function (y
    = - x*x ; if coordinate system positioned on the vertical axe of square; y
    is oriented vertical up, x horizontal; )?

    Is it possible to state some mathematical function for curve in sketch and
    then use part of it for a sketch of a part?

    Thanks in advance.

    Best regards.
     
    strela, Dec 24, 2007
    #1
  2. The one that comes to mind based on your post is to use Insert> curve>
    Curve through XYZ points, then browse to a file created by Excel or
    whatever that delivers a dataset from the calculation that you are
    running.
    Keep in mind that equations in SWx can do a lot, or simple sketch
    relations (if you really know your trig) can pull off amazing things,
    and I would suggest that you look at those with a creative eye -
    especialy simple sketch relations, which I have seen underutilized so
    many times.
    But based on the vague request - the "for instance..." I suspect that
    importing a dataset to use with "curve through XYZ points" is what you
    want.
    Good luck, and let us know if this doesn't work so you can come back
    with a more specific problem -with more detail - for us to comment on.
    Ed
     
    Edward T Eaton, Dec 26, 2007
    #2
  3. strela

    Cliff Guest

    A mathematical function has at most one value for Y for each value of X.
    Your "curve" would also have non-continuous derivatives at the "corners"
    and thus could not be represented by a polynomial, such as a NURBS curve.
    Now, there are things called step functions and other series approximations
    (such as Fouier series) but ...
     
    Cliff, Dec 26, 2007
    #3
  4. strela

    That70sTick Guest

    If all you need is a parabola (y = ax^2 + bX + c), SW has a parabola
    entity in the sketch entities menu. Draw and constrain accordingly.
     
    That70sTick, Dec 26, 2007
    #4
  5. strela

    TOP Guest

    This comes to mind. A simple macro. You do the math. If you want 3D
    use a 3D spline. Paste the text below into an empty macro.

    TOP

    Option Explicit

    '
    ******************************************************************************
    ' macro recorded on 12/26/07 by kellnerp
    '
    ******************************************************************************
    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    boolstatus = Part.Extension.SelectByID("Front Plane", "PLANE", 0, 0,
    0, False, 0, Nothing)
    boolstatus = Part.Extension.SelectByID("Front Plane", "PLANE", 0, 0,
    0, False, 0, Nothing)
    Part.InsertSketch2 True
    Part.ClearSelection2 True

    Dim x0, xn, a, b, c As Double
    Dim x(20), y(20) As Double
    Dim i As Long

    x0 = 0#
    xn = 1#
    a = 2#
    b = 2#
    c = 2#

    'y=ax^2+bx+c

    For i = 0 To 20
    x(i) = x0 + (xn - x0) / 20 * i
    y(i) = a * x(i) * x(i) + b * x(i) + c
    Part.SketchSpline 20 - i, x(i) * 0.0254, y(i) * 0.0254, 0
    Next i

    Part.ClearSelection2 True
    Part.InsertSketch2 True
    End Sub
     
    TOP, Dec 27, 2007
    #5
  6. strela

    takedown Guest

    takedown, Dec 28, 2007
    #6
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.