Set Text in Datum Tags and GTols Example (VBA)
This example shows how to set the text in datum tags and geometric
tolerances.
'----------------------------------------------------------------------------
' Preconditions: Open a drawing that contains one view, a datum feature, and
' a geometric tolerance.
'
' Postconditions: Each annotation is appended with the specified text.
' ---------------------------------------------------------------------------
Dim swApp
As SldWorks.SldWorks
Dim swModel
As SldWorks.ModelDoc2
Dim swModelView
As SldWorks.ModelView
Dim swDraw
As SldWorks.DrawingDoc
Dim swView
As SldWorks.View
Dim swDispGtol
As SldWorks.Gtol
Dim swDatumTag
As SldWorks.DatumTag
Dim Rect
As Variant
Option Explicit
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelView = swModel.ActiveView
Set swDraw = swModel
Set swView = swDraw.GetFirstView 'sheet
Set swView = swView.GetNextView
Set swDispGtol = swView.GetFirstGTOL
swDispGtol.SetText swGTolTextPrefix, "prefix"
swDispGtol.SetText swGTolTextSuffix, "suffix"
swDispGtol.SetText swGTolTextCalloutAbove, "above"
swDispGtol.SetText swGTolTextCalloutBelow, "below"
Set swDatumTag = swView.GetFirstDatumTag
swDatumTag.SetText swDatumTagTextPrefix, "prefix"
swDatumTag.SetText swDatumTagTextSuffix, "suffix"
swDatumTag.SetText swDatumTagTextCalloutAbove, "above"
swDatumTag.SetText swDatumTagTextCalloutBelow, "below"
Set Rect = Nothing
swModelView.GraphicsRedraw (Rect)
End Sub