Hide Table of Contents

Get Types of Entities for Selected Dimension Example (VBA)

This example shows how to get the type of entities for a selected dimension.

 

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

'

' Preconditions: Dimension selected for which you

'                want to get the attached entities.

'

' Postconditions: None

'

' NOTE: A dangling dimension has at least

'       one entity of type swSelNOTHING.

'

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

Option Explicit

Public Enum swAnnotationType_e

    swCThread = 1

    swDatumTag = 2

    swDatumTargetSym = 3

    swDisplayDimension = 4

    swGTol = 5

    swNote = 6

    swSFSymbol = 7

    swWeldSymbol = 8

    swCustomSymbol = 9

    swDowelSym = 10

    swLeader = 11

    swBlock = 12

    swCenterMarkSym = 13

    swTableAnnotation = 14

    swCenterLine = 15

End Enum

Public Enum swSelectType_e

    swSelNOTHING = 0

    swSelEDGES = 1              '  "EDGE"

    swSelFACES = 2              '  "FACE"

    swSelVERTICES = 3           '  "VERTEX"

    swSelSKETCHSEGS = 10        '  "SKETCHSEGMENT"

    swSelSKETCHPOINTS = 11      '  "SKETCHPOINT"

    swSelGTOLS = 13             '  "GTOL"

    swSelDIMENSIONS = 14        '  "DIMENSION"

    swSelNOTES = 15             '  "NOTE"

    swSelCENTERMARKS = 28       '  "CENTERMARKS"

    swSelSFSYMBOLS = 35         '  "SFSYMBOL"

    swSelDATUMTAGS = 36         '  "DATUMTAG"

    swSelCTHREADS = 39          '  "CTHREAD"

    swSelDTMTARGS = 40          '  "DTMTARG"

    swSelBLOCKINST = 93         '  "BLOCKINST"

    swSelCENTERMARKSYMS = 100   '  "CENTERMARKSYMS"

    swSelCENTERLINES = 103      '  "CENTERLINE"

End Enum

 

Sub main()

 

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swSelObj                As Object

    Dim swAnn                   As SldWorks.Annotation

    Dim vAttEntTypeArr          As Variant

    Dim vAttEntArr              As Variant

    Dim nSelType                As Long

    Dim i                       As Long

    Dim bRet                    As Boolean

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swSelObj = swSelMgr.GetSelectedObject5(1)

    Set swAnn = swSelObj.GetAnnotation

    

    Debug.Print "Name              = " & swAnn.GetName

    Debug.Print "  Selection Type  = " & swSelMgr.GetSelectedObjectType2(1)

    Debug.Print "  Annotation Type = " & swAnn.GetType

    

    vAttEntArr = swAnn.GetAttachedEntities2

    vAttEntTypeArr = swAnn.GetAttachedEntityTypes

    

    If Not IsEmpty(vAttEntTypeArr) Then

        Debug.Assert UBound(vAttEntArr) = UBound(vAttEntTypeArr)

        For i = 0 To UBound(vAttEntTypeArr)

            ' A dangling dimension has at least one entity of type swSelNOTHING

            Debug.Print "  Entity Type(" & i & ")  = " & vAttEntTypeArr(i)

        Next i

    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 Types of Entities for Selected Dimension 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) 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.