Hide Table of Contents

Get Style Spline Curve Type Example (VBA)

This example shows how to create a style spline and get its type of curve.

'---------------------------------------------------
' Preconditions:
' 1. Verify that the specified part template exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Opens a new part document.
' 2. Creates a style spline.
' 3. Selects the style spline.
' 4. Gets whether the selection is a style spline 
'    and, if so, gets its curve type.
' 5. Examine the Immediate window.
'---------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSketchManager As SldWorks.SketchManager
Dim swSketchSegment As SldWorks.SketchSegment
Dim swSketchSpline As SldWorks.SketchSpline
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim pointArray As Variant
Dim points() As Double
Dim status As Boolean
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2016\templates\part.prtdot", 0, 0, 0)
    ' Create style spline
    ReDim points(0 To 32) As Double
    points(0) = -0.068952134919552
    points(1) = 8.71923799128056E-03
    points(2) = 0
    points(3) = -5.63242730011457E-02
    points(4) = 1.85409083722633E-02
    points(5) = 0
    points(6) = -4.18924308086813E-02
    points(7) = 8.71923799128056E-03
    points(8) = 0
    points(9) = -2.04451097726579E-02
    points(10) = 2.43537336997836E-02
    points(11) = 0
    points(12) = 6.21370983286659E-03
    points(13) = -1.25276407920698E-02
    points(14) = 0
    points(15) = 2.44539548261202E-02
    points(16) = -4.50995068514512E-03
    points(17) = 0
    points(18) = 3.30729716910642E-02
    points(19) = 6.31393095920317E-03
    points(20) = 0
    points(21) = 0.048306582894221
    points(22) = 1.17258717813773E-02
    points(23) = 0
    points(24) = 0.05852913778055
    points(25) = -6.11348870653004E-03
    points(26) = 0
    points(27) = 6.53441743714359E-02
    points(28) = -1.07236605180117E-02
    points(29) = 0
    points(30) = -999999999
    points(31) = -999999999
    points(32) = -999999969
    pointArray = points
    Set swSketchManager = swModel.SketchManager
    Set swSketchSegment = swSketchManager.CreateSpline2((pointArray), True)
    swModel.ClearSelection2 True
    swSketchManager.InsertSketch True
    
    ' Get whether selection is style spline and, if so, get its curve type
    Set swModelDocExt = swModel.Extension
    status = swModelDocExt.SelectByID2("Spline1@Sketch1", "EXTSKETCHSEGMENT", -3.11890911939585E-02, 1.22942518144824E-02, 0, False, 0, Nothing, 0)
    Set swSelectionMgr = swModel.SelectionManager
    Set swSketchSpline = swSelectionMgr.GetSelectedObject6(1, -1)
    status = swSketchSpline.IsStyleSpline
    Debug.Print "Is the selection a style spline? " & status
    If status Then
        Debug.Print "Style spline curve type (3 = swStyleSplineCurveType_e.BSpline_Degree7): " & swSketchSpline.CurveType
    End If    
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 Style Spline Curve Type 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) 2025 SP2

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.