Set Text in Datum Tags and GTols Example (VB.NET)
This example shows how to set the text in datum tags and geometric
tolerances.
'----------------------------------------------------------------------------
' Preconditions:
' 1. Open a drawing that contains at least one view, a datum feature,
' and a geometric tolerance.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Appends the specified text to each annotation.
' 2. Gets the datum tag label.
' 3. Examine the Immediate window.
'
---------------------------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports
System
Imports System.Diagnostics
Partial
Class
SolidWorksMacro
Dim
swModel As
ModelDoc2
Dim
swModelView As
ModelView
Dim
swDraw As
DrawingDoc
Dim
swView As
View
Dim
swDispGtol As
Gtol
Dim
swDatumTag As
DatumTag
Dim
rect() As
Double
Sub
main()
swModel = swApp.ActiveDoc
swModelView = swModel.ActiveView
swDraw = swModel
swView = swDraw.GetFirstView
'sheet
swView = swView.GetNextView
swDispGtol = swView.GetFirstGTOL
swDispGtol.SetText(swGTolTextParts_e.swGTolTextPrefix,
"prefix")
swDispGtol.SetText(swGTolTextParts_e.swGTolTextSuffix,
"suffix")
swDispGtol.SetText(swGTolTextParts_e.swGTolTextCalloutAbove,
"above")
swDispGtol.SetText(swGTolTextParts_e.swGTolTextCalloutBelow,
"below")
swDatumTag = swView.GetFirstDatumTag
swDatumTag.SetText(swDatumTagTextParts_e.swDatumTagTextPrefix,
"prefix")
swDatumTag.SetText(swDatumTagTextParts_e.swDatumTagTextSuffix,
"suffix")
swDatumTag.SetText(swDatumTagTextParts_e.swDatumTagTextCalloutAbove,
"above")
swDatumTag.SetText(swDatumTagTextParts_e.swDatumTagTextCalloutBelow,
"below")
Debug.Print("Datum
tag label: " & swDatumTag.GetLabel)
rect = Nothing
swModelView.GraphicsRedraw(rect)
End
Sub
Public
swApp As
SldWorks
End
Class