Hide Table of Contents

Set Tangent Vectors for Sketch Points Example (VBA)

This example shows how to set the tangent vectors for sketch points in a spline.

 

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

'

' Preconditions:

'       (1) Sketch of spline is open.

'       (2) A frame point exists in the sketch.

'

' Postconditions: Tangent vectors are set for the sketch points of the spline.

'

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

Option Explicit

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSketch                As SldWorks.sketch

    Dim vSkPtArr                As Variant

    Dim vSkPt                   As Variant

    Dim swSkPt                  As SldWorks.SketchPoint

    Dim vTangent                As Variant

    Dim bRet                    As Boolean

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSketch = swModel.GetActiveSketch2

    

    vSkPtArr = swSketch.GetSketchPoints

    

    For Each vSkPt In vSkPtArr

        Set swSkPt = vSkPt

        

        vTangent = swSkPt.GetFramePointTangent(bRet)

        ' Positions before adjusting spline tangency

        If bRet Then

            Debug.Print "  Pt [" & swSkPt.GetId(0) & ", " & swSkPt.GetId(1) & "]"

            Debug.Print "    Pos          = (" & swSkPt.x * 1000# & ", " & swSkPt.y * 1000# & ", " & swSkPt.z * 1000# & ") mm"

        End If

    Next vSkPt

    

    For Each vSkPt In vSkPtArr

        Set swSkPt = vSkPt

        

        vTangent = swSkPt.GetFramePointTangent(bRet)

        ' Positions after adjusting spline tangency

        If bRet Then

            Debug.Print "  Pt [" & swSkPt.GetId(0) & ", " & swSkPt.GetId(1) & "]"

            Debug.Print "    Pos          = (" & swSkPt.x * 1000# & ", " & swSkPt.y * 1000# & ", " & swSkPt.z * 1000# & ") mm"

            

            Debug.Print "  Old  tangent = (" & vTangent(0) & ", " & vTangent(1) & ")"

        

            vTangent(0) = vTangent(0) + 0.01

            vTangent(1) = vTangent(1) + 0.01

            

            Debug.Print "  New1 tangent = (" & vTangent(0) & ", " & vTangent(1) & ")"

            

            bRet = swSkPt.SetFramePointTangent((vTangent))

        

            vTangent = swSkPt.GetFramePointTangent(bRet)

            

            Debug.Print "  Pos          = (" & swSkPt.x * 1000# & ", " & swSkPt.y * 1000# & ", " & swSkPt.z * 1000# & ") mm"

            Debug.Print "  New2 tangent = (" & vTangent(0) & ", " & vTangent(1) & ")"

        End If

    Next vSkPt

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:   Set Tangent Vectors for Sketch Points 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.