我可以使用 COM api 过滤 AutoCAD SelectionSet 吗?

Can I filter an AutoCAD SelectionSet with the COM api?

我正在为 AutoCAD 编写一个外部工具(使用 COM api),我需要过滤一个 SelectionSet,但我无法找出 "FilterType" 和 "FilterData" 参数.

我知道它已经过时了,但我需要使用 COM api,而且我一辈子都找不到任何文档。有更多经验的人可以帮助我吗?

这些是有问题的行:

AcadApplication app = Marshal.GetActiveObject(AppID) as AcadApplication;
AcadSelectionSet SelectionSet = app.ActiveDocument.SelectionSets.Add(name);

int[] filterType = new int[1];
object[] filterData = new object[1];

filterType[0] = (int)DxfCode.BlockName;
filterData[0] = "T-siman";

SelectionSet.SelectOnScreen(filterType, filterData);

最后一行returns出现如下异常: System.ArgumentException: 'Invalid argument FilterType in SelectOnScreen'

我一直在寻找解决方案,因为我被卡住了,但后来我找到了 THIS QUESTION 并注意到此人使用 "short" 类型的数组而不是 "int" 类型的数组 "FilterType" 参数。这样做对我有用。

我的工作代码:

AcadApplication app = Marshal.GetActiveObject(AppID) as AcadApplication;
AcadSelectionSet SelectionSet = app.ActiveDocument.SelectionSets.Add(name);

short[] filterType = new short[1];
object[] filterData = new object[1];

filterType[0] = (short)DxfCode.BlockName;
filterData[0] = "T-siman";

SelectionSet.SelectOnScreen(filterType, filterData);