> Set Text in Datum Tags and GTols Example (C#)
Welcome
Getting Started
SolidWorks API Help
FeatureWorks API Help
SolidWorks Document Manager API Help
eDrawings API Help
SolidWorks Routing API Help
SolidWorks Simulation API Help
SolidWorks Utilities API Help
SolidWorks Workgroup PDM API Help
Hide Table of Contents Show Table of Contents

Set Text in Datum Tags and GTols Example (C#)

This example shows how to set the text in datum tags and geometric tolerances.

//----------------------------------------------------------------------------
// Preconditions:
// 1. Open a drawing that contains one view, a datum feature,
//    and a geometric tolerance.
// 2. Ensure that the namespace matches the name of your C# project.
//
// Postconditions: Each annotation is appended with the specified text.
// ---------------------------------------------------------------------------
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
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");

            swModelView.GraphicsRedraw(rect);

        }


        
public SldWorks swApp;
    }
}

 



Related SolidWorks Forum Content

Provide feedback on this topic

SolidWorks welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Set Text in Datum Tags and GTols Example (C#)
*Comment:  
x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2012 SP05

The search functionality within the web help is in a beta test phase and you may experience periodic delays or interruptions in its performance. These are the normal and ordinary features of a beta test and shall not under any circumstances give rise to any liability on the part of DS SolidWorks or its licensors. The topics within the Web-based help are not beta topics; they document API Help (English only) 2012 SP05.

To disable Web help from within SolidWorks and use local help instead, click Help > Use SolidWorks Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.