This example shows how to get chamfer display dimension properties.
This example also shows how to set and get lower display dimension text.
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
bRet = swModel.Extension.SelectByID2("RD1@Drawing View1",
"DIMENSION", 0.4935677398765, 0.3280800260301, 0, False, 0, Nothing, 0)
Set swDispDim = swSelMgr.GetSelectedObject6(1, 0)
swModel.ClearSelection2 True
Debug.Print "Dimension type as defined in swDimensionType_e:
" & swDispDim.Type2 '10=swChamferDimension
Debug.Print ""
Debug.Print "Uses document units? " & swDispDim.GetUseDocUnits 'false if uses
local override units
If swDispDim.GetUseDocUnits = False Then
Dim LenUnit As Long
Dim AngUnit As Long
bRet = swDispDim.GetChamferUnits(LenUnit, AngUnit)
Debug.Print "Uses local length unit as defined in
swLengthUnit_e: " & LenUnit '0=swMM
Debug.Print "Uses local angle unit as defined in
swAngleUnit_e: " & AngUnit '0=swDegrees, 3=swRadians
End If
Debug.Print ""
Dim indx As Long
indx = swDispDim.ChamferPrecision(0)
Debug.Print "Precision of chamfer distance: " & indx & " decimal places"
indx = swDispDim.ChamferPrecision(1)
Debug.Print "Precision of chamfer angle: " & indx & " decimal places"
Dim tokenformats As Variant
Dim tokenvalues As Variant
Dim tokenformat As String
Dim n As Long
Debug.Print ""
Debug.Print "Text format items in " & swDispDim.GetNameForSelection & ":"
Debug.Print ""
Dim count As Long
count =
swDispDim.GetTextFormatItems(swDimensionTextParts_e.swDimensionTextCalloutAbove,
tokenformats, tokenvalues)
Debug.Print "Number of callout above items: " & count
If Not count = 0 Then
Debug.Print " tokenformats: "
For n = LBound(tokenformats) To UBound(tokenformats)
Debug.Print " " &
tokenformats(n)
Next n
Debug.Print " tokenvalues: "
For n = LBound(tokenvalues) To UBound(tokenvalues)
Debug.Print " " &
tokenvalues(n)
Next n
End If
Debug.Print ""
count =
swDispDim.GetTextFormatItems(swDimensionTextParts_e.swDimensionTextPrefix,
tokenformats, tokenvalues)
Debug.Print "Number of prefix items: " & count
If Not count = 0 Then
Debug.Print " tokenformats: "
For n = LBound(tokenformats) To UBound(tokenformats)
Debug.Print " " &
tokenformats(n)
Next n
Debug.Print " tokenvalues: "
For n = LBound(tokenvalues) To UBound(tokenvalues)
Debug.Print " " & tokenvalues(n)
Next n
End If
Debug.Print ""
count =
swDispDim.GetTextFormatItems(swDimensionTextParts_e.swDimensionTextSuffix,
tokenformats, tokenvalues)
Debug.Print "Number of suffix items: " & count
If Not count = 0 Then
Debug.Print " tokenformats: "
For n = LBound(tokenformats) To UBound(tokenformats)
Debug.Print " " &
tokenformats(n)
Next n
Debug.Print " tokenvalues: "
For n = LBound(tokenvalues) To UBound(tokenvalues)
Debug.Print " " & tokenvalues(n)
Next n
End If
Debug.Print ""
count =
swDispDim.GetTextFormatItems(swDimensionTextParts_e.swDimensionTextCalloutBelow,
tokenformats, tokenvalues)
Debug.Print "Number of callout below items: " & count
If Not count = 0 Then
Debug.Print " tokenformats: "
For n = LBound(tokenformats) To UBound(tokenformats)
Debug.Print " " &
tokenformats(n)
Next n
Debug.Print " tokenvalues: "
For n = LBound(tokenvalues) To UBound(tokenvalues)
Debug.Print "" & tokenvalues(n)
Next n
End If
' Create lower display dimension text and enclose
' in parentheses
swDispDim.SetLowerText ("Example of lower text")
swDispDim.ShowLowerParenthesis = True
Debug.Print ("")
Debug.Print ("Lower Dimension Text: " & swDispDim.GetLowerText)
Debug.Print (" Show lower parenthesis: " & swDispDim.ShowLowerParenthesis)
Debug.Print (" Show lower inspection: " & swDispDim.LowerInspection)
Debug.Print (" Split dual dimensions: " & swDispDim.Split)