Hide Table of Contents

Get Annotation Object Example (VB.NET)

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.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics


Partial Class SolidWorksMacro

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

    
Sub main()

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

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

        Debug.Print("Annotation: " & Anno.GetName)

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