I am trying to create a macro from one of the API help example (modified) to show the dimension type
When I run the code, I am getting the error (highlighted)
Can someone please correct the code to get it working?. (I am not a VB expert and trying to learn thru the SW API Examples)
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDraw As DrawingDoc
Dim swView As SldWorks.View
Dim swDispDim As SldWorks.DisplayDimension
Dim swDim As SldWorks.Dimension
Dim swAnnotation As SldWorks.Annotation
Dim swDisplayDimension As SldWorks.DisplayDimension
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAnnotation = swDraw.GetFirstAnnotation2
Do While (Not (swAnnotation Is Nothing))
Debug.Print " "
Debug.Print "Annotation name = " & swAnnotation.GetName
If swAnnotationType_e.swDisplayDimension = swAnnotation.GetType Then
Debug.Print " Is a display dimension? True"
Set swDisplayDimension = swAnnotation.GetSpecificAnnotation
Select Case (swDisplayDimension.Type2)
Case swDimensionType_e.swOrdinateDimension
Debug.Print " Display dimension type = base ordinate and its subordinates"
Case swDimensionType_e.swLinearDimension
Debug.Print " Display dimension type = linear"
Case swDimensionType_e.swAngularDimension
Debug.Print " Display dimension type = angular"
Case swDimensionType_e.swArcLengthDimension
Debug.Print " Display dimension type = arc length"
Case swDimensionType_e.swRadialDimension
Debug.Print " Display dimension type = radial"
Case swDimensionType_e.swDiameterDimension
Debug.Print " Display dimension type = diameter"
Case swDimensionType_e.swHorOrdinateDimension
Debug.Print " Display dimension type = horizontal ordinate"
Case swDimensionType_e.swVertOrdinateDimension
Debug.Print " Display dimension type = vertical ordinate"
Case swDimensionType_e.swZAxisDimension
Debug.Print " Display dimension type = z-axis"
Case swDimensionType_e.swChamferDimension
Debug.Print " Display dimension type = chamfer dimension"
Case swDimensionType_e.swHorLinearDimension
Debug.Print " Display dimension type = horizontal linear"
Case swDimensionType_e.swVertLinearDimension
Debug.Print " Display dimension type = vertical linear"
Case swDimensionType_e.swScalarDimension
Debug.Print " Display dimension type = scalar"
Case Else
Debug.Print " Display dimension type = unknown"
End Select
End If
Loop
End Sub
Thanks in advance
JOHN
SolidworksApi macros