Clearing the Active SelectionSet

What does the Clear method on the ActiveSelectionSet do.

After I have the user select some items on the drawing, I do some processing.

Then I want to clear the selected (and highlighted items) so I do the following (myActiveDoc is a reference to the Active Document)

myActiveDoc.ActiveSelectionSet.Clear()

After doing this, the property myActiveDoc.ActiveSelectionSet.Count is not zero as I would expect.

Another question, are selected items necessarily highlighted. Is there a way of unhighlighting all items?

Thank you , Mark Bosley

 

Comments

  • Hi Mark,

    This code seems to work as advertised, you may be needing to cache a copy of the ActiveSet to variable.

     


     public static class Commands
      {
        [CommandMethod("doit")]
        public static void test01()
        {
          var app = Application.AcadApplication as AcadApplication;
          var doc = app.ActiveDocument;
          try
          {
            AcadSelectionSet aset = doc.ActiveSelectionSet;
            doc.Utility.Prompt(String.Format("\n{0}", aset.Count));
            foreach (AcadEntity e in aset)
              e.Highlight(true);
            //foreach (AcadEntity e in aset)
             // e.Highlight(false);
            aset.Clear();
            doc.Utility.Prompt(String.Format("\n{0}", aset.Count));
            aset.Delete();
          }
          catch (System.Exception ex)
          {
            doc.Utility.Prompt(String.Format("\n{0}", ex.Message));
          }
        }
      }
This discussion has been closed.