[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
public static AcadSelectionSet SelectEntityOnScreen(this AcadApplication Ca, short[] groupcpde, object[] datacode, string strSsetname = "SELECTION~TEXT~1111")
{
AcadDocument zdoc = Ca.ActiveDocument;
foreach (AcadSelectionSet SetItem in zdoc.SelectionSets)
{
if (SetItem.Name == strSsetname)
{
SetItem.Delete();
break;
}
}
AcadSelectionSet objSset = zdoc.SelectionSets.Add(strSsetname);
SetForegroundWindow((IntPtr)Ca.HWND);
objSset.SelectOnScreen(groupcpde, datacode);
return objSset;
}