Hide Table of Contents

Get, Set, And Remove Tracking IDs On Vertex (VBA)

This example shows how to get, set, and remove tracking IDs on a vertex. Tracking IDs reliably associate application-specific data across modeling operations.

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

' Preconditions: Part document with a single part is open.

'                The selected vertex has not been

'                assigned any tracking IDs.

'

' Directions:     Run the macro once, and the

'                 the selected vertex is assigned

'                 a tracking ID of 12. Run

'                 the macro again, and the selected vertex

'                 is assigned tracking ID of 16. The

'                 the tracking ID is then deleted from the

'                 vertex.

'

' Postconditions: None

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

Option Explicit

 

Sub main()

 

    Dim swApp               As SldWorks.SldWorks

    Dim swModel             As SldWorks.ModelDoc2

    Dim swModelExtn         As ModelDocExtension

    Dim swSelMgr            As SldWorks.SelectionMgr

    Dim swVertex            As SldWorks.Vertex

    Dim Cookies             As Long

    Dim vTrackingIDs        As Variant

    Dim TrackingID          As Long

    Dim bRebuild            As Boolean

 

    Set swApp = CreateObject("SldWorks.Application")

    

    Cookies = swApp.RegisterTrackingDefinition("Tracking_API")

    If (Cookies = -1) Then

        End  ' No valid cookies found

    End If

    

    Stop

    

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    

    Stop ' Select vertex on the part

        

    Set swVertex = swSelMgr.GetSelectedObject6(1, -1)

        

    Debug.Print "---------------------------------"

    Dim NbrTrackingIds As Long

    NbrTrackingIds = swVertex.GetTrackingIDsCount(Cookies)

    Debug.Print "Vertex Tracking IDs:"

    If (NbrTrackingIds = 0) Then

    

        Debug.Print "  No tracking IDs"

        Debug.Print "    Setting tracking ID..."

        Debug.Print "      SetTrackingID Result (if 0, then call successful): " & swVertex.SetTrackingID(Cookies, 12)

        Debug.Print "      GetTrackingIDs Result (if 0, then call successful): " & swVertex.GetTrackingIDs(Cookies, vTrackingIDs)

        Debug.Print "      Tracking ID after SetTrackingID call : " & vTrackingIDs(0)

        End

     

    Else

    

        Debug.Print "  Tracking IDs exist..."

        Debug.Print "    Getting tracking ID..."

        Debug.Print "      GetTrackingIDs Result (if 0, then call successful): " & swVertex.GetTrackingIDs(Cookies, vTrackingIDs)

        Debug.Print "      Tracking ID before SetTracingID call : " & vTrackingIDs(0)

        

        Debug.Print " "

        Debug.Print "      SetTrackingID Result (if 0, then call successful): " & swVertex.SetTrackingID(Cookies, 16)

        Debug.Print "      GetTrackingIDs Result (if 0, then call successful): " & swVertex.GetTrackingIDs(Cookies, vTrackingIDs)

        Debug.Print "      Tracking ID after SetTrackingID call: " & vTrackingIDs(0)

        Debug.Print " "

        Debug.Print "      Remove Tracking ID..."

        Debug.Print "        RemoveTrackingID Result (if 0, then call successful): " & swVertex.RemoveTrackingID(Cookies)

        Debug.Print "        Number of tracking IDs on this body: " & swVertex.GetTrackingIDsCount(Cookies)

        

        Debug.Print "---------------------------------"

        

   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, Set, And Remove Tracking IDs On Vertex (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) 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.