Get BOM Balloon Properties Example (VBA)
This example shows how to get the properties of a BOM balloon.
'---------------------------------------------------
'
' Preconditions:
' (1)
Model document is open.
' (2)
BOM balloon is selected.
'
' Postconditions: None
'
'----------------------------------------------------
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"
End Enum
Public Enum swBalloonStyle_e
swBS_None
= 0
swBS_Circular
= 1
swBS_Triangle
= 2
swBS_Hexagon
= 3
swBS_Box
= 4
swBS_Diamond
= 5
swBS_SplitCirc
= 6
swBS_Pentagon
= 7
swBS_FlagPentagon
= 8
swBS_FlagTriangle
= 9
swBS_Underline
= 10
End Enum
Public Enum swDetailingNoteTextContent_e
swDetailingNoteTextCustom
= 1
swDetailingNoteTextItemNumber
= 2
swDetailingNoteTextQuantity
= 3
End Enum
Public Enum swBalloonFit_e
swBF_Tightest
= 0
swBF_1Char
= 1
swBF_2Chars
= 2
swBF_3Chars
= 3
swBF_4Chars
= 4
swBF_5Chars
= 5
End Enum
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.modelDoc
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swNote As
SldWorks.note
Dim
swAnn As
SldWorks.Annotation
Dim
vAttEntArr As
Variant
Dim
vAttEntTypeArr As
Variant
Dim
swEnt As
SldWorks.entity
Dim
swComp As
SldWorks.component
Dim
swCompModel As
SldWorks.modelDoc
Dim
i As
Long
Dim
bRet As
Boolean
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swNote = swSelMgr.GetSelectedObject5(1)
Set
swAnn = swNote.GetAnnotation
Debug.Assert
swNote.IsBomBalloon
vAttEntArr
= swAnn.GetAttachedEntities2:
If IsEmpty(vAttEntArr) Then Exit Sub
vAttEntTypeArr
= swAnn.GetAttachedEntityTypes
Debug.Assert
UBound(vAttEntArr) = UBound(vAttEntTypeArr)
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" Name
=
" & swAnn.GetName
Debug.Print
" Upper
text =
" & swNote.GetBomBalloonText(True)
& " [" & swNote.GetBomBalloonTextStyle(True) & "]"
Debug.Print
" Lower
text =
" & swNote.GetBomBalloonText(False)
& " [" & swNote.GetBomBalloonTextStyle(False) &
"]"
Debug.Print
" Balloon
fit =
" & swNote.GetBalloonSize
Debug.Print
" Balloon
style =
" & swNote.GetBalloonStyle
Debug.Print
" Is
stacked =
" & swNote.IsStackedBalloon
Debug.Print
" Is
stacked master =
" & swNote.IsStackedBalloonMaster
For
i = 0 To UBound(vAttEntArr)
Debug.Print
" AttEntType
=
" & vAttEntTypeArr(i)
If
swSelNOTHING <> vAttEntTypeArr(i) Then
Set
swEnt = vAttEntArr(i)
Set
swComp = swEnt.GetComponent
Set
swCompModel = swComp.GetModelDoc
Debug.Print
" AttEnt
=
" & swComp.GetPathName
& " <" & swComp.ReferencedConfiguration
& ">" & " --> " & swCompModel.GetPathName
End
If
Next
i
End Sub
'---------------------------------------------------