1. [DllImport("User32.dll", CharSet = CharSet.Unicode)]
    2. public static extern bool SetForegroundWindow(IntPtr hWnd);
    3. public static AcadSelectionSet SelectEntityOnScreen(this AcadApplication Ca, short[] groupcpde, object[] datacode, string strSsetname = "SELECTION~TEXT~1111")
    4. {
    5. AcadDocument zdoc = Ca.ActiveDocument;
    6. foreach (AcadSelectionSet SetItem in zdoc.SelectionSets)
    7. {
    8. if (SetItem.Name == strSsetname)
    9. {
    10. SetItem.Delete();
    11. break;
    12. }
    13. }
    14. AcadSelectionSet objSset = zdoc.SelectionSets.Add(strSsetname);
    15. SetForegroundWindow((IntPtr)Ca.HWND);
    16. objSset.SelectOnScreen(groupcpde, datacode);
    17. return objSset;
    18. }