C# Solidworks二次开发:几何公差IGot相关操作API详解

大家好,今天要介绍的是关于几何公差IGot相关操作的API。

几何公差之前没有讲过,具体API如下面所示:

(1)第一个为GetText,这个API的含义为获取此几何公差的指定文本部分,下面是官方的具体解释:

其输入参数有一个为swGTolTextParts_e,在API定义有四种,分别为:

swGTolTextCalloutAbove3
swGTolTextCalloutBelow4
swGTolTextPrefix1
swGTolTextSuffix2

返回值为文本内容。

(2)第二个为GetTextCount,这个API的含义为获取此几何公差的文本项数,下面是官方的具体解释:

其没有输入参数,只有输出参数,参数为文本对象数量。

下面是官方使用的例子:

This example shows how to get text items, values, and symbols in a GTol frame.

//-------------------------------------------------------------
// Preconditions:
// 1. Open document with a GTol frame and select that GTol 
//    frame.
// 2. Open the Immediate window.
//
// Postconditions: 
// 1. Gets the text items, values, and symbols in the 
//    selected GTol frame.
// 2. Examine the Immediate window.
//-------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
 
namespace Macro1CSharp.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));
            }
            int count = 0;
            count = swGtol.GetFrameCount();
            count = count - 1;
            Debug.Print("GetFrameCount = " + count.ToString());
            for (int idx = 1; idx <= (swGtol.GetFrameCount() - 1); idx++)
            {
                Object myParams;
                Object mySymbols;
                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));
                    mySymbols = swGtol.GetFrameSymbols3((short)idx);
                    Array mySymbolsArray = (Array)mySymbols;
                    Debug.Print("  GetFrameSymbols3(" + idx.ToString() + ") = " + mySymbolsArray.GetValue(0) + "," + mySymbolsArray.GetValue(1) + "," + mySymbolsArray.GetValue(2) + "," + mySymbolsArray.GetValue(3) + "," + mySymbolsArray.GetValue(4) + "," + mySymbolsArray.GetValue(5));
  
                }
            }
 
        }
 
        /// <summary>
        ///  The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
        public SldWorks swApp;
    }
}

(3)第三个为GetTextFont,这个API的含义为获取此几何公差的字体,下面是官方的具体解释:

其没有输入参数,返回参数值为几何公差字体的名称。

(4)第四个为GetTextPoint,这个API的含义为获取几何公差的文本参考点,该点是边界矩形左上角,下方是官方的具体解释:

上面就是本篇文章的全部内容,我们下篇文章再见。

  • 25
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵桑さん

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值