Hide Table of Contents

Get Text Items in GTol Frame Example (C#)

This example shows how to get each text item (for example, datum tag text and  tolerance value) in a GTol frame.

//-------------------------------------------------------------

// Preconditions:

// 1. Open document with a GTol frame and select that GTol frame.

// 2. Open the Immediate window.

// 3. Run the macro.

//

// Postconditions: Number of text items and values for the selected GTol

// frame are printed to the Immediate window.

//-------------------------------------------------------------

using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swconst;

using System.Diagnostics;

using System;

namespace GetTextCountGtolCSharp.csproj

{

    public partial class SolidWorksMacro

    {

        public void Main()

        {

            ModelDoc2 swModel;

            ModelDocExtension swModelDocExt;

            SelectionMgr swSelMgr;

            Gtol swGtol;

            

            swModel = (ModelDoc2)swApp.ActiveDoc;

            swModelDocExt = (ModelDocExtension)swModel.Extension;

            swSelMgr = (SelectionMgr)swModel.SelectionManager;

            swGtol = (Gtol)swSelMgr.GetSelectedObject6(1, -1);

            Debug.Print("GetTextCount = " + swGtol.GetTextCount().ToString());

            

            for(int idx=0;idx < swGtol.GetTextCount();idx++)

            {

                Debug.Print("GetTextAtIndex(" + idx.ToString() + ") = " + swGtol.GetTextAtIndex(idx));

            }

            Debug.Print("GetFrameCount = " + swGtol.GetFrameCount().ToString());

            for(int idx=1;idx <= swGtol.GetFrameCount();idx++)

            {

                Object myParams;

                myParams = swGtol.GetFrameValues((short)idx);

                if (myParams != null)

                {

                    Array myParamArray = (Array)myParams;

                    Debug.Print("GetFrameValues(" + idx.ToString() + ") = " + myParamArray.GetValue(0) + "," + myParamArray.GetValue(1) + "," + myParamArray.GetValue(2) + "," + myParamArray.GetValue(3) + "," + myParamArray.GetValue(4));

                }

            }

        }

        /// <summary>

        ///  The SldWorks swApp variable is pre-assigned for you.

        /// </summary>

        public SldWorks swApp;

    }

}



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:   Get Text Items in GTol Frame Example (C#)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



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) 2014 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.