> Create Equation-driven Curve Example (VB.NET)
Welcome
Getting Started
SolidWorks API Help
FeatureWorks API Help
SolidWorks Document Manager API Help
eDrawings API Help
SolidWorks Routing API Help
SolidWorks Simulation API Help
SolidWorks Utilities API Help
SolidWorks Workgroup PDM API Help
Hide Table of Contents Show Table of Contents

Create Equation-driven Curve (VB.NET)

This example shows how to create and modify an equation-driven curve.

'---------------------------------------------------------------

' Preconditions:  Part document is open in SolidWorks.

'

' Postconditions: A 2D sketch is created, and an equation spline of a

' sine curve is created.  After the break point, the curve is edited

' and a cosine curve is created.

'----------------------------------------------------------------

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System

Imports System.Diagnostics

 

Partial Class SolidWorksMacro

 

#Region "Macro Variables"

    Dim swModel As ModelDoc2

    Dim swExt As ModelDocExtension

    Dim swSelMgr As SelectionMgr

    Dim boolstatus As Boolean

    Dim y As String

    Dim r1 As Double

    Dim r2 As Double

    Dim rad As Boolean

    Dim ang As Double

    Dim xOff As Double, yOff As Double

    Dim LockStart As Boolean, LockEnd As Boolean

#End Region

 

    Public Sub main()

        swModel = swApp.ActiveDoc

        swExt = swModel.Extension

        swSelMgr = swModel.SelectionManager

        boolstatus = swExt.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

        swModel.SketchManager.InsertSketch(True)

        swModel.ClearSelection2(True)

        Dim skSegment As SketchSegment

        skSegment = swModel.SketchManager.CreateEquationSpline2("sin(x)", "", "", "0", "6.28", false, 0, 0.002, 0.002, false, false)

        swModel.ViewZoomtofit2()

        Stop

        Dim skSpline As SketchSpline

        skSpline = skSegment

        Call skSpline.GetEquationParameters(y, r1, r2, rad, ang, xOff, yOff, LockStart, LockEnd)

        Debug.Print("x: " & x)

        Debug.Print("y: " & y)

        Debug.Print("var param: " & v)

        Debug.Print("range start: " & r1)

        Debug.Print("range end: " & r2)

        Debug.Print("radian?: " & rad)

        Debug.Print("ang offset: " & ang)

        Debug.Print("x offset: " & xOff)

        Debug.Print("y offset: " & yOff)

        Debug.Print("Lock start: " & LockStart)

        Debug.Print("Lock end: " & LockEnd)

        Debug.Print("-----------------------------")

        'Change spline to a cosine curve

        y = "cos(x)"

        Call skSpline.SetEquationParameters(y, r1, r2, rad, ang, xOff, yOff, LockStart, LockEnd)

    End Sub

 

    ''' <summary>

    ''' The SldWorks swApp variable is pre-assigned for you.

    ''' </summary>

    Public swApp As SldWorks

 

End Class

 



Related SolidWorks Forum Content

Provide feedback on this topic

SolidWorks welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Equation-driven Curve Example (VB.NET)
*Comment:  
x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2012 SP05

The search functionality within the web help is in a beta test phase and you may experience periodic delays or interruptions in its performance. These are the normal and ordinary features of a beta test and shall not under any circumstances give rise to any liability on the part of DS SolidWorks or its licensors. The topics within the Web-based help are not beta topics; they document API Help (English only) 2012 SP05.

To disable Web help from within SolidWorks and use local help instead, click Help > Use SolidWorks Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.