<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove selected item from on screen selection in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3784976#M51054</link>
    <description>&lt;P&gt;I'm not sure I'm reading it right or this is a topic I don't know much about.&lt;/P&gt;&lt;P&gt;But, if you want to deselect something (at this point you should have a SelectionSet built through an ObjectId array - ObjectId[]) can't you just create a new SelectionSet without the ObjectId selected for deselection and then set the new Implied selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("test1", CommandFlags.UsePickSet|CommandFlags.Redraw)]
public void test1()
{
  //You may create the original seletion here or already have it at this point
  
  //Ask for an object to deselect
  ObjectId[] MyObjectIds = new ObjectId[count-1];
  //Create new selection without the object to deselect
  newEditor.SetImpliedSelection(MyObjectIds);
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Or maybe what you want is to get the current selection after the deselecting objects (Shift + Click) which would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("test2", CommandFlags.UsePickSet|CommandFlags.Redraw)]
public void test2()
{
  Document newDoc = Application.DocumentManager.MdiActiveDocument;
  Editor newEditor = newDoc.Editor;

  PromptSelectionResult newPSR = newEditor.SelectImplied();

  if (newPSR.Status == PromptStatus.Error)
  {
    //This happens when nothing was selected when using SelectImplied()
    //You may ommit this control and just use the next one, not sure, try it either way.
  }
  if (newPSR.Status == PromptStatus.OK)
  {
    //Do something with the selection.
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;You need to commandflag UsePickSet to use SelectImplied and that other function correctly.&lt;/P&gt;&lt;P&gt;You need Redraw for your new selection to show properly after using newEditor.Regen(); which you should add at the end of your commands if you want to regenerate the current view of AutoCAD model space.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Feb 2013 14:03:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-02-20T14:03:37Z</dc:date>
    <item>
      <title>Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3782569#M51052</link>
      <description>&lt;P&gt;I have other related posts but felt this was a separate question that could deserve its own post so here goes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I presently have code that will select objects on screen based on particular stored object handles. &amp;nbsp;The code then prompts the user to add additional selections once these handle selections are made. &amp;nbsp;No problem. &amp;nbsp;The problem lies with attempting to deselect the objects that were selected via object handles. &amp;nbsp;I should say highlighted because that is what the present code is doing. &amp;nbsp;It is highlighting the objects on screen. &amp;nbsp;The code I am using follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                Dim ids(1) As ObjectId
                ids(0) = ObjectIdFromHandle(myDocDB, "1D6")
                ids(1) = ObjectIdFromHandle(myDocDB, "1DE")
                Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids)

                '  Get the Pickfirst selection set
                Dim acSSPrompt As PromptSelectionResult
                acSSPrompt = ed.SelectImplied()

                Dim Objs As ObjectIdCollection
                If acSSPrompt.Status = PromptStatus.OK Then
                    Objs = New ObjectIdCollection(acSSPrompt.Value.GetObjectIds)
                Else
                    Objs = New ObjectIdCollection
                End If

                ed.SetImpliedSelection(New ObjectId(-1) {})
                If Objs.Count &amp;gt; 0 Then
                    HighlightEntities(Objs)
                End If
                acSSPrompt = ed.GetSelection()
                If acSSPrompt.Status = PromptStatus.OK Then
                    For Each obj As ObjectId In acSSPrompt.Value.GetObjectIds
                        Objs.Add(obj)
                    Next
                    Dim ids2 As ObjectId() = New ObjectId(Objs.Count - 1) {}
                    Objs.CopyTo(ids, 0)
                    ed.SetImpliedSelection(ids2)
                End If


    Private Sub HighlightEntities(objIds As ObjectIdCollection)
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim tr As Transaction = doc.TransactionManager.StartTransaction()
        Using tr
            For Each objId As ObjectId In objIds
                Dim ent As Entity = TryCast(tr.GetObject(objId, OpenMode.ForRead), Entity)
                If ent IsNot Nothing Then
                    ent.Highlight()

                End If
            Next
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help anyone can provide.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2013 21:51:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3782569#M51052</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-16T21:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3784679#M51053</link>
      <description>&lt;P&gt;Highlighting and selecting are two very different things.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem you have is that you want to allow a user to 'edit' a selection. Unfortunately, there is no built-in API that allows that. &amp;nbsp;It can be done, but involves the use of a kludge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See &lt;A target="_blank" href="http://www.theswamp.org/index.php?topic=43970.0"&gt;this swamp post&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 05:06:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3784679#M51053</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-02-20T05:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3784976#M51054</link>
      <description>&lt;P&gt;I'm not sure I'm reading it right or this is a topic I don't know much about.&lt;/P&gt;&lt;P&gt;But, if you want to deselect something (at this point you should have a SelectionSet built through an ObjectId array - ObjectId[]) can't you just create a new SelectionSet without the ObjectId selected for deselection and then set the new Implied selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("test1", CommandFlags.UsePickSet|CommandFlags.Redraw)]
public void test1()
{
  //You may create the original seletion here or already have it at this point
  
  //Ask for an object to deselect
  ObjectId[] MyObjectIds = new ObjectId[count-1];
  //Create new selection without the object to deselect
  newEditor.SetImpliedSelection(MyObjectIds);
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Or maybe what you want is to get the current selection after the deselecting objects (Shift + Click) which would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("test2", CommandFlags.UsePickSet|CommandFlags.Redraw)]
public void test2()
{
  Document newDoc = Application.DocumentManager.MdiActiveDocument;
  Editor newEditor = newDoc.Editor;

  PromptSelectionResult newPSR = newEditor.SelectImplied();

  if (newPSR.Status == PromptStatus.Error)
  {
    //This happens when nothing was selected when using SelectImplied()
    //You may ommit this control and just use the next one, not sure, try it either way.
  }
  if (newPSR.Status == PromptStatus.OK)
  {
    //Do something with the selection.
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;You need to commandflag UsePickSet to use SelectImplied and that other function correctly.&lt;/P&gt;&lt;P&gt;You need Redraw for your new selection to show properly after using newEditor.Regen(); which you should add at the end of your commands if you want to regenerate the current view of AutoCAD model space.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 14:03:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3784976#M51054</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-20T14:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785057#M51055</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;I'm not sure I'm reading it right or this is a topic I don't know much about.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;He &lt;SPAN&gt;&lt;SPAN class="hps"&gt;wants to give&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the user ability to&lt;/SPAN&gt; operate with previous selected &lt;SPAN class="hps"&gt;entities&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;(add&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;new primitives to selectionset or remove &lt;/SPAN&gt;&lt;SPAN class="hps"&gt;existing&lt;/SPAN&gt; entities from selectionset&lt;SPAN class="hps"&gt;).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hps"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="hps"&gt;Tony (&lt;SPAN class="UserName lia-user-name"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1052889"&gt;@DiningPhilosopher&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/a&gt;&lt;/SPAN&gt;)&amp;nbsp;&lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;did exactly&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;what&lt;/SPAN&gt; @Anonymous&amp;nbsp;&lt;SPAN class="hps"&gt;asked. &lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;And he did it&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;very beautiful&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in his own style&lt;/SPAN&gt;&lt;SPAN&gt;!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 14:46:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785057#M51055</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-20T14:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785084#M51056</link>
      <description>&lt;P&gt;hmm...Never heard of a kludge.&amp;nbsp; I will need to look into this.&amp;nbsp; I will also look at the swamp post and see what I can make work.&amp;nbsp; Thanks for the link&amp;nbsp; &lt;A target="_self" href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1052889"&gt;&lt;SPAN&gt;DiningPhilosopher&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alexander, was your response to Tony a sarcastic response or do you agree with Tony's response and Swamp post?&amp;nbsp; Just curious. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, I will let you know how I make out.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 15:01:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785084#M51056</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-20T15:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Remove selected item from on screen selection</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785105#M51057</link>
      <description>&lt;P&gt;&lt;SPAN class="hps"&gt;&lt;SPAN class="hps"&gt;No&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;sarcasm!&lt;/SPAN&gt; &lt;SPAN&gt;&lt;SPAN class="hps"&gt;I respect&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Tony for&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;his knowledge and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;for the fact that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;he shares&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;this knowledge&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;with others.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I believe that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;this forum&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is&amp;nbsp;&lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;at a high level&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;thanks to&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Tony!&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;If you do not&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;be lazy and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;read this&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;forum, you&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;will find that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Tony&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;answers the questions&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;more than a dozen&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;years.&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;He's&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the only one who&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;dedicate&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a separate &lt;A href="https://forums.autodesk.com/t5/NET/What-happens-with-Tony-Tanzillo/m-p/2800448#M21090" target="_self"&gt;topic&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;&lt;A href="https://forums.autodesk.com/t5/NET/What-happens-with-Tony-Tanzillo/m-p/2800448#M21090" target="_self"&gt;on this forum&lt;/A&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 15:11:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-selected-item-from-on-screen-selection/m-p/3785105#M51057</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-20T15:11:49Z</dc:date>
    </item>
  </channel>
</rss>

