//----------------------------------------------------------------------------
// Preconditions:
// 1. Open a drawing that contains at least one view, a datum feature,
// and a geometric tolerance.
// 2. Open the Immediate window.
// 3. Run the macro.
//
// Postconditions:
// 1. The specified text is appended to each annotation.
// 2. Datum tag label is printed to the Immediate
window.
//
---------------------------------------------------------------------------
using
System;
using
System.Diagnostics;
using
SolidWorks.Interop.sldworks;
using
SolidWorks.Interop.swconst;
namespace
SetText_CSharp.csproj
{
partial
class
SolidWorksMacro
{
ModelDoc2
swModel;
ModelView
swModelView;
DrawingDoc
swDraw;
View
swView;
Gtol
swDispGtol;
Double[]
rect = null;
DatumTag
swDatumTag;
public
void
Main()
{
swModel = (ModelDoc2)swApp.ActiveDoc;
swModelView = (ModelView)swModel.ActiveView;
swDraw = (DrawingDoc)swModel;
swView = (View)swDraw.GetFirstView();
//sheet
swView = (View)swView.GetNextView();
swDispGtol = (Gtol)swView.GetFirstGTOL();
swDispGtol.SetText((int)swGTolTextParts_e.swGTolTextPrefix,
"prefix");
swDispGtol.SetText((int)swGTolTextParts_e.swGTolTextSuffix,
"suffix");
swDispGtol.SetText((int)swGTolTextParts_e.swGTolTextCalloutAbove,
"above");
swDispGtol.SetText((int)swGTolTextParts_e.swGTolTextCalloutBelow,
"below");
swDatumTag = (DatumTag)swView.GetFirstDatumTag();
swDatumTag.SetText((int)swDatumTagTextParts_e.swDatumTagTextPrefix,
"prefix");
swDatumTag.SetText((int)swDatumTagTextParts_e.swDatumTagTextSuffix,
"suffix");
swDatumTag.SetText((int)swDatumTagTextParts_e.swDatumTagTextCalloutAbove,
"above");
swDatumTag.SetText((int)swDatumTagTextParts_e.swDatumTagTextCalloutBelow,
"below");
Debug.Print("Datum
tag label: " + swDatumTag.GetLabel());
swModelView.GraphicsRedraw(rect);
}
public
SldWorks
swApp;
}
}