Hide Table of Contents

Get Annotation Object Example (VBA)

This example shows how to obtain the annotation object for the selected annotation symbol.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open a model document that contains an annotation symbol.
' 2. Select the annotation symbol.
'
' Postconditions: The annotation object for the selected symbol is obtained.
' ---------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim AnnoObject As Object
Dim aWeldSymbol As SldWorks.WeldSymbol
Dim aWeldBead As SldWorks.WeldBead
Dim aView As SldWorks.View
Dim aTableAnno As SldWorks.TableAnnotation
Dim anSFSymbol As SldWorks.SFSymbol
Dim aRevisionCloud As SldWorks.RevisionCloud
Dim aNote As SldWorks.Note
Dim aLeader As SldWorks.MultiJogLeader
Dim aGtol As SldWorks.Gtol
Dim aDowelSym As SldWorks.DowelSymbol
Dim aDispDim As SldWorks.DisplayDimension
Dim aDatTarSym As SldWorks.DatumTargetSym
Dim aDatumTag As SldWorks.DatumTag
Dim aDatumOrigin As SldWorks.DatumOrigin
Dim aCustomSymbol As SldWorks.CustomSymbol
Dim aCenterMark As SldWorks.CenterMark
Dim aCenterLine As SldWorks.CenterLine
Dim aCThread as SldWorks.CThread
Dim Anno As SldWorks.Annotation

Option Explicit
Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    Set AnnoObject = SelMgr.GetSelectedObject6(1, -1)
 

    Select Case SelMgr.GetSelectedObjectType3(1, -1)
        Case swSelWELDS:
            Debug.Print "Selected annotation is a WeldSymbol."
            Set aWeldSymbol = AnnoObject
            Set Anno = aWeldSymbol.GetAnnotation
        Case swSelWELDBEADS:
            Debug.Print "Selected annotation is a WeldBead."
            Set aWeldBead = AnnoObject
            Set Anno = aWeldBead.GetAnnotation
        Case swSelDRAWINGVIEWS:
            Debug.Print "Selected annotation is a View."
            Set aView = AnnoObject
            Set Anno = aView.GetAnnotation
        Case swSelANNOTATIONTABLES
            Debug.Print "Selected annotation is a TableAnnotation."
            Set aTableAnno = AnnoObject
            Set Anno = aTableAnno.GetAnnotation
        Case swSelSFSYMBOLS
            Debug.Print "Selected annotation is an SFSymbol."
            Set anSFSymbol = AnnoObject
            Set Anno = anSFSymbol.GetAnnotation
        Case swSelREVISIONCLOUDS
            Debug.Print "Selected annotation is a RevisionCloud."
            Set aRevisionCloud = AnnoObject
            Set Anno = aRevisionCloud.GetAnnotation
        Case swSelNOTES
            Debug.Print "Selected annotation is a Note."
            Set aNote = AnnoObject
            Set Anno = aNote.GetAnnotation
        Case swSelLEADERS
            Debug.Print "Selected annotation is a Leader."
            Set aLeader = AnnoObject
            Set Anno = aLeader.GetAnnotation
        Case swSelGTOLS
            Debug.Print "Selected annotation is a Gtol."
            Set aGtol = AnnoObject
            Set Anno = aGtol.GetAnnotation
        Case swSelDOWELSYMS
            Debug.Print "Selected annotation is a DowelSymbol."
            Set aDowelSym = AnnoObject
            Set Anno = aDowelSym.GetAnnotation
        Case swSelDIMENSIONS
            Debug.Print "Selected annotation is a DisplayDimension."
            Set aDispDim = AnnoObject
            Set Anno = aDispDim.GetAnnotation
        Case swSelDTMTARGS
            Debug.Print "Selected annotation is a DatumTargetSym."
            Set aDatTarSym = AnnoObject
            Set Anno = aDatTarSym.GetAnnotation
        Case swSelDATUMTAGS
            Debug.Print "Selected annotation is a DatumTag."
            Set aDatumTag = AnnoObject
            Set Anno = aDatumTag.GetAnnotation
        Case swSelDATUMPOINTS
            Debug.Print "Selected annotation is a DatumOrigin."
            Set aDatumOrigin = AnnoObject
            Set Anno = aDatumOrigin.GetAnnotation
        Case swSelCUSTOMSYMBOLS
            Debug.Print "Selected annotation is a CustomSymbol."
            Set aCustomSymbol = AnnoObject
            Set Anno = aCustomSymbol.GetAnnotation
        Case swSelCTHREADS
            Debug.Print "Selected annotation is a CThread."
            Set aCThread = AnnoObject
            Set Anno = aCThread.GetAnnotation
        Case swSelCENTERMARKSYMS
            Debug.Print "Selected annotation is a CenterMark."
            Set aCenterMark = AnnoObject
            Set Anno = aCenterMark.GetAnnotation
        Case swSelCENTERLINES
            Debug.Print "Selected annotation is a CenterLine."
            Set aCenterLine = AnnoObject
            Set Anno = aCenterLine.GetAnnotation
    End Select
   

    Debug.Print "Annotation: " & Anno.GetName
   

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 Annotation Object 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.