大家好,今天要介绍的是关于几何公差IGot相关操作的API。
几何公差之前没有讲过,具体API如下面所示:
(1)第一个为GetText,这个API的含义为获取此几何公差的指定文本部分,下面是官方的具体解释:
其输入参数有一个为swGTolTextParts_e,在API定义有四种,分别为:
swGTolTextCalloutAbove | 3 |
swGTolTextCalloutBelow | 4 |
swGTolTextPrefix | 1 |
swGTolTextSuffix | 2 |
返回值为文本内容。
(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的含义为获取几何公差的文本参考点,该点是边界矩形左上角,下方是官方的具体解释:
上面就是本篇文章的全部内容,我们下篇文章再见。