Hide Table of Contents

Get Annotations Example (VB.NET)

This example shows how to get the annotations of a model.

'---------------------------------------------------------------------------- 
' Preconditions:
' 1. Open a model with one or more annotations.
' 2. Open an Immediate window.
'
' Postconditions: All the annotations are printed in the Immediate window.
'----------------------------------------------------------------------------

Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

    
Public Sub main()

        
Dim swModel As ModelDoc2
        
Dim swModelDocExt As ModelDocExtension
        
Dim swAnnotation As Annotation
        
Dim iAnnoCnt As Integer
        Dim arrAnnotation As Object
        Dim i As Integer
        Dim IAnnoType As Integer

        swModel = swApp.ActiveDoc
        swModelDocExt = swModel.Extension

        iAnnoCnt = swModelDocExt.GetAnnotationCount()

        
If iAnnoCnt > 0 Then
            arrAnnotation = swModelDocExt.GetAnnotations()

            
For i = LBound(arrAnnotation) To UBound(arrAnnotation)

                swAnnotation = arrAnnotation(i)

                IAnnoType = swAnnotation.GetType()

                
Select Case IAnnoType

                    
Case 1
                        Debug.Print(
"Annotation: Thread")

                    
Case 2
                        Debug.Print(
"Annotation: Datum Tag")

                    
Case 3
                        Debug.Print(
"Annotation: Datum Target Symbol")

                    
Case 4
                        Debug.Print(
"Annotation: Display Diamension")

                    
Case 5
                        Debug.Print(
"Annotation: Gtol")

                    
Case 6
                        Debug.Print(
"Annotation: Note")

                    
Case 7
                        Debug.Print(
"Annotation: SFS Symbol")

                    
Case 8
                        Debug.Print(
"Annotation: Weld Symbol")

                    
Case 9
                        Debug.Print(
"Annotation: Custom Symbol")

                    
Case 10
                        Debug.Print(
"Annotation: Dowel Symbol")

                    
Case 11
                        Debug.Print(
"Annotation: Leader")

                    
Case 12
                        Debug.Print(
"Annotation: Block")

                    
Case 13
                        Debug.Print(
"Annotation: Center Mark symbol")

                    
Case 14
                        Debug.Print(
"Annotation: Table Annotation")

                    
Case 15
                        Debug.Print(
"Annotation: Center Line ")

                    
Case 16
                        Debug.Print(
"Annotation: Datum Origin")

                
End Select
            Next
        End If
    End Sub

  
    
Public swApp As SldWorks


End Class

 



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 Annotations Example (VB.NET)
*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) 2017 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.