Hide Table of Contents

Get Start and End Points of Spline Example (VBA)

This example shows how to get the start and end points of a spline.

 

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

'

' Preconditions:

'         (1) Sketch is active.

'         (2) Spline is selected.

'

' Postconditions: None

'

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

Option Explicit

Public Enum swSketchSegments_e

    swSketchLINE = 0

    swSketchARC = 1

    swSketchELLIPSE = 2

    swSketchSPLINE = 3

    swSketchTEXT = 4

    swSketchPARABOLA = 5

End Enum

' Define two types

Type DoubleRec

    dValue As Double

End Type

Type Long2Rec

    iLower As Long

    iUpper As Long

End Type

' Extract two integer values from a single double value

' by assigning a DoubleRec to the double value,

' copying the value to a Long2Rec, and

' extracting the integer values

Function ExtractFields _

( _

    ByVal dValue As Double, _

    iLower As Long, _

    iUpper As Long _

)

    Dim dr                          As DoubleRec

    Dim i2r                         As Long2Rec

    ' Set the double value

    dr.dValue = dValue

    ' Copy the values

    LSet i2r = dr

    ' Extract the values

    iLower = i2r.iLower

    iUpper = i2r.iUpper

End Function

Sub main()

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swSelMgr                    As SldWorks.SelectionMgr

    Dim swSketchSeg                 As SldWorks.SketchSegment

    Dim swCurve                     As SldWorks.Curve

    Dim nStartParam                 As Double

    Dim nEndParam                   As Double

    Dim bIsClosed                   As Boolean

    Dim bIsPeriodic                 As Boolean

    Dim vStart                      As Variant

    Dim vEnd                        As Variant

    Dim nDummy                      As Long

    Dim nStartSuccess               As Long

    Dim nEndSuccess                 As Long

    Dim i                           As Long

    Dim bRet                        As Boolean

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swSketchSeg = swSelMgr.GetSelectedObject5(1)

    Set swCurve = swSketchSeg.GetCurve

    

    bRet = swCurve.GetEndParams(nStartParam, nEndParam, bIsClosed, bIsPeriodic)

    Debug.Assert bRet

    

    vStart = swCurve.Evaluate(nStartParam)

    vEnd = swCurve.Evaluate(nEndParam)

    

    ExtractFields vStart(6), nStartSuccess, nDummy

    ExtractFields vEnd(6), nEndSuccess, nDummy

    Debug.Assert nStartSuccess

    Debug.Assert nEndSuccess

    

    Debug.Print "Length = " & swCurve.GetLength2(nStartParam, nEndParam) * 1000# & " mm"

    Debug.Print "  Start Pt     = (" & vStart(0) * 1000# & ", " & vStart(1) * 1000# & ", " & vStart(2) * 1000# & ") mm"

    Debug.Print "    tangent    = (" & vStart(3) & ", " & vStart(4) & ", " & vStart(5) & ")"

    Debug.Print "  End   Pt     = (" & vEnd(0) * 1000# & ", " & vEnd(1) * 1000# & ", " & vEnd(2) * 1000# & ") mm"

    Debug.Print "    tangent    = (" & vEnd(3) & ", " & vEnd(4) & ", " & vEnd(5) & ")"

End Sub



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:   Get Start and End Points of Spline Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

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) 2015 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.