Hide Table of Contents

Get Reference Curve Information Example (VBA)

This example shows how to get information about a reference curve (for example, a projected curve) through a set of points.

 

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

'

' Preconditions:

'       (1) Part or assembly is open.

'       (2) Reference curve is selected in the FeatureManager design tree.

'           This code does not work if the reference curve is selected

'           in the graphics area.

'

' Postconditions: None

'

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

Option Explicit

Function TessLength _

( _

    vTessPts As Variant _

) As Double

    Dim i                       As Long

    

    For i = 0 To ((UBound(vTessPts) + 1) / 3 - 2)

        TessLength = TessLength + _

                Sqr( _

                    (vTessPts(3 * i + 0) - vTessPts(3 * i + 3)) ^ 2# + _

                    (vTessPts(3 * i + 1) - vTessPts(3 * i + 4)) ^ 2# + _

                    (vTessPts(3 * i + 2) - vTessPts(3 * i + 5)) ^ 2# _

                    )

    Next i

End Function

Sub main()

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swSelMgr                    As SldWorks.SelectionMgr

    Dim swFeat                      As SldWorks.feature

    Dim swRefCurve                  As SldWorks.ReferenceCurve

    Dim swEdge                      As SldWorks.Edge

    Dim swCurve                     As SldWorks.curve

    Dim vCurveParam                 As Variant

    Dim nStartPt(2)                 As Double

    Dim nEndPt(2)                   As Double

    Dim vStartPt                    As Variant

    Dim vEndPt                      As Variant

    Dim vTessPts                    As Variant

    Dim i                           As Long

    Dim bRet                        As Boolean

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swFeat = swSelMgr.GetSelectedObject5(1)

    Set swRefCurve = swFeat.GetSpecificFeature

    Set swEdge = swRefCurve.GetFirstSegment

    

    Debug.Print "Feat = " & swFeat.Name

    

    While Not swEdge Is Nothing

        Set swCurve = swEdge.GetCurve

    

        vCurveParam = swEdge.GetCurveParams2

    

        nStartPt(0) = vCurveParam(0)

        nStartPt(1) = vCurveParam(1)

        nStartPt(2) = vCurveParam(2)

        

        nEndPt(0) = vCurveParam(3)

        nEndPt(1) = vCurveParam(4)

        nEndPt(2) = vCurveParam(5)

        

        vStartPt = nStartPt

        vEndPt = nEndPt

        

        vTessPts = swCurve.GetTessPts(0.000001, 0.000001, (vStartPt), (vEndPt))

        

        Debug.Print "  Curve(" & i & ")"

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

        Debug.Print "    End    = (" & vCurveParam(3) * 1000# & ", " & vCurveParam(4) * 1000# & ", " & vCurveParam(5) * 1000# & ") mm"

        Debug.Print "    Length = " & swCurve.GetLength2(vCurveParam(6), vCurveParam(7)) * 1000# & " mm"

    

        Debug.Print "    TessLength(" & UBound(vTessPts) & ")  = " & TessLength(vTessPts) * 1000# & " mm"

        

        i = i + 1

        

        Set swEdge = swRefCurve.GetNextSegment

    Wend

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 Reference Curve Information 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) 2013 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.