求助:c#与AutoCad2004问题
以下代码是在AUTOCAD2004下的VBA代码
''''''选择集
Public Sub MySelet()
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Dim Mssname As String
Mssname = "temp"
Dim sset As AcadSelectionSet
On Error Resume Next
Set sset = ThisDrawing.SelectionSets.Add(Mssname)
If Err Then
Set sset = ThisDrawing.SelectionSets.Item(Mssname)
End If
On Error GoTo 0
FilterType(0) = 0: FilterData(0) = "LWPOLYLINE"
sset.Clear
sset.SelectOnScreen FilterType, FilterData
If sset.Count > 0 Then
Set Ment = sset(0)
MsgBox "选择线:" & sset.Count & "条"
Else
MsgBox "没有选线"
End If
End Sub
下面是C#中实现类似功能的代码:
using System;
using System.Collections.Generic;
using System.Text;
using AutoCAD;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ZZXACAD
{
public class MyAcad
{
const string progID = "AutoCAD.Application.16";
AcadApplication acApp;
AcadDocument acDoc = null;
private string acadFile;
public int MySelet(string sName)
{
int []
FilterType = new int[1] { 0 };
object[] FilterData = new object[1] { "LWPOLYLINE" };
AcadSelectionSet sset = null;
try
{
sset = acDoc.SelectionSets.Add(sName);
}
catch
{
sset = acDoc.SelectionSets.Item(sName);
}
sset.Clear();
try
{
sset.SelectOnScreen((object)FilterType, (object)FilterData);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "errr");
}
return sset.Count;
}
}
}
}
C#代码“sset.SelectOnScreen((object)FilterType, (object)FilterData);”为什么总出现错误:参数FilterType(位于SelectOnScreen中)无效。”
恳请请大侠们指点迷经!