<?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: Any way to get points used in GetSelection? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708202#M39444</link>
    <description>&lt;P&gt;Never mind,&amp;nbsp;I figured it out myself. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  class CommandShowPoints
  {
    Point3dCollection m_pts = new Point3dCollection();
    public CommandShowPoints()
    {
      Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
      PromptSelectionOptions pso = new PromptSelectionOptions();
      ed.PointMonitor += ed_PointMonitor;
      PromptSelectionResult psr = ed.GetSelection();
      ed.PointMonitor -= ed_PointMonitor;
      if (psr.Status == PromptStatus.Cancel) return;
&lt;BR /&gt;      ed.WriteMessage("\nList of picked points\n");
      foreach (Point3d pt in m_pts) 
      {
        ed.WriteMessage(string.Format("\n{0}", pt)); 
      }
    }

    void ed_PointMonitor(object sender, PointMonitorEventArgs e)
    {
      Point3d ptLast = e.Context.LastPoint;&lt;BR /&gt;      if ((ptLast != Point3d.Origin) &amp;amp;&amp;amp; (m_pts.Contains(e.Context.LastPoint) == false)) &lt;BR /&gt;      {&lt;BR /&gt;        m_pts.Add(e.Context.LastPoint);&lt;BR /&gt;      }
    }
  }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, is there any way to know if the user select a "Window", "Crossing", "WindowPolygon" etc for the selection? I am not interested in querying the entities that are in the selection set, using the "SelectedObject.SelectionMethod", since the&amp;nbsp;window /&amp;nbsp; crossing / whatever, may not result in a SelectionSet at all.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jul 2015 05:20:00 GMT</pubDate>
    <dc:creator>deltacadd</dc:creator>
    <dc:date>2015-07-07T05:20:00Z</dc:date>
    <item>
      <title>Any way to get points used in GetSelection?</title>
      <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5706564#M39443</link>
      <description>&lt;P&gt;Is there any way to retrieve the list of points used for selecting objects&amp;nbsp;when the Editor.GetSelection() method is run?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command: MyCommand&lt;/P&gt;&lt;P&gt;Select objects: WP&lt;/P&gt;&lt;P&gt;First polygon point: &amp;lt;Point picked&amp;gt;&lt;/P&gt;&lt;P&gt;Specify endpoint of line or [Undo]: &amp;lt;Point picked&amp;gt;&lt;/P&gt;&lt;P&gt;Specify endpoint of line or [Undo]: &amp;lt;Point picked&amp;gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Specify endpoint of line or [Undo]: &amp;lt;ENTER&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list of points is: &amp;lt;x,y&amp;gt;,&amp;lt;x,y&amp;gt;,&amp;lt;x,y&amp;gt;,&amp;lt;x,y&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jul 2015 09:59:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5706564#M39443</guid>
      <dc:creator>deltacadd</dc:creator>
      <dc:date>2015-07-06T09:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get points used in GetSelection?</title>
      <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708202#M39444</link>
      <description>&lt;P&gt;Never mind,&amp;nbsp;I figured it out myself. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  class CommandShowPoints
  {
    Point3dCollection m_pts = new Point3dCollection();
    public CommandShowPoints()
    {
      Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
      PromptSelectionOptions pso = new PromptSelectionOptions();
      ed.PointMonitor += ed_PointMonitor;
      PromptSelectionResult psr = ed.GetSelection();
      ed.PointMonitor -= ed_PointMonitor;
      if (psr.Status == PromptStatus.Cancel) return;
&lt;BR /&gt;      ed.WriteMessage("\nList of picked points\n");
      foreach (Point3d pt in m_pts) 
      {
        ed.WriteMessage(string.Format("\n{0}", pt)); 
      }
    }

    void ed_PointMonitor(object sender, PointMonitorEventArgs e)
    {
      Point3d ptLast = e.Context.LastPoint;&lt;BR /&gt;      if ((ptLast != Point3d.Origin) &amp;amp;&amp;amp; (m_pts.Contains(e.Context.LastPoint) == false)) &lt;BR /&gt;      {&lt;BR /&gt;        m_pts.Add(e.Context.LastPoint);&lt;BR /&gt;      }
    }
  }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, is there any way to know if the user select a "Window", "Crossing", "WindowPolygon" etc for the selection? I am not interested in querying the entities that are in the selection set, using the "SelectedObject.SelectionMethod", since the&amp;nbsp;window /&amp;nbsp; crossing / whatever, may not result in a SelectionSet at all.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 05:20:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708202#M39444</guid>
      <dc:creator>deltacadd</dc:creator>
      <dc:date>2015-07-07T05:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get points used in GetSelection?</title>
      <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708293#M39445</link>
      <description>&lt;P&gt;The following sample evaluate the Selection details, inclusive the Picked Points. No need for Point monitor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("TestSelection")]
        public static void TestSelection()
        {
            Document doc = null;
            Database db = null;
            Editor ed = null;

            try
            {
                doc = AcadApp.DocumentManager.MdiActiveDocument;
                if (doc == null)
                    throw new System.Exception("\n Drawing Document required");
                db = doc.Database;
                ed = doc.Editor;

                //Select Objects, use ed.GetSelection to benefit from Window/Crossing selection visual feedback
                PromptSelectionOptions pso = new PromptSelectionOptions();
                pso.MessageForAdding = "Select  Objects";
                pso.SingleOnly = false;
                PromptSelectionResult psr = ed.GetSelection(pso);
                if (psr.Status != PromptStatus.OK)
                    return;

                SelectionSetDelayMarshalled ssMarshal = (SelectionSetDelayMarshalled)psr.Value;
                AdsName name = ssMarshal.Name;
                var selObjIds = ssMarshal.GetObjectIds();
                ed.WriteMessage("\n {0} Objects selected", selObjIds.Length);
                for (int i = 0; i &amp;lt; selObjIds.Length; i++)
                    ed.WriteMessage("\n\t [{0}]: {1} ({2})", i, selObjIds[i].ObjectClass.DxfName, selObjIds[i].Handle);

                SelectionSet selSet = (SelectionSet)ssMarshal;
                ed.WriteMessage("\n {0} Selections in SelectionSet", selSet.Count);

                foreach (SelectedObject ssItem in selSet)
                {
                    ed.WriteMessage("\n\t {0} Selected: {1} ({2})", Enum.GetName(typeof(SelectionMethod), ssItem.SelectionMethod), ssItem.ObjectId.ObjectClass.DxfName, ssItem.ObjectId.Handle);
                    switch (ssItem.SelectionMethod)
                    {
                        case SelectionMethod.PickPoint:
                            PickPointSelectedObject ppSelObj = ssItem as PickPointSelectedObject;
                            Point3d pickedPoint = ppSelObj.PickPoint.PointOnLine;
                            ed.WriteMessage("\n\t\t Selected at: {0}", pickedPoint.ToString());
                            break;

                        case SelectionMethod.Crossing:
                            CrossingOrWindowSelectedObject crossSelObj = ssItem as CrossingOrWindowSelectedObject;
                            PickPointDescriptor[] crossSelPickedPoints = crossSelObj.GetPickPoints();
                            ed.WriteMessage("\n\t\t Crossing at: {0}..{1}", crossSelPickedPoints[0].PointOnLine.ToString(), crossSelPickedPoints[1].PointOnLine.ToString());
                            break;

                        case SelectionMethod.Window:
                            CrossingOrWindowSelectedObject windSelObj = ssItem as CrossingOrWindowSelectedObject;
                            PickPointDescriptor[] winSelPickedPoints = windSelObj.GetPickPoints();
                            ed.WriteMessage("\n\t\t Window at: {0}..{1}", winSelPickedPoints[0].PointOnLine.ToString(), winSelPickedPoints[1].PointOnLine.ToString());
                            break;

                    }
                }
            }
            catch (System.Exception ex)
            {
                if (ed != null)
                    ed.WriteMessage(ex.Message);
                else
                    System.Windows.Forms.MessageBox.Show(ex.Message,
                                "TestSelection",
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Error);
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2015 07:42:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708293#M39445</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-07-07T07:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get points used in GetSelection?</title>
      <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708532#M39446</link>
      <description>&lt;P&gt;Not sure why, but running the above code shows the last two points for all the entities, if I have selected say a Window Polygon. See example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG title="FAP.jpg" alt="FAP.jpg" src="https://forums.autodesk.com/t5/image/serverpage/image-id/177380i08E865BFF2B68B00/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Command: tss

Select  Objects: wp

First polygon point:
Specify endpoint of line or [Undo]:
Specify endpoint of line or [Undo]:
Specify endpoint of line or [Undo]:
Specify endpoint of line or [Undo]:
Specify endpoint of line or [Undo]:
Specify endpoint of line or [Undo]:
12 found

Select  Objects:

 12 Objects selected
 12 Selections in SelectionSet
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)
Window at: 
(1886.16856979758,755.163512841775,0)..(1888.90531905888,952.047645899205,0)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Except for commenting the additional WriteMessages, no other change to the code you have supplied. Any idea why this is happening?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 11:43:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708532#M39446</guid>
      <dc:creator>deltacadd</dc:creator>
      <dc:date>2015-07-07T11:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get points used in GetSelection?</title>
      <link>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708663#M39447</link>
      <description>&lt;P&gt;The sample assumed rectangular window (or crossing) selections only. For polygone selections use this &lt;EM&gt;slightly&lt;/EM&gt; modified code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                           ...&lt;BR /&gt; PickPointDescriptor[] crossSelPickedPoints = crossSelObj.GetPickPoints();
                            if (crossSelPickedPoints != null)
                            {
                                for (int i = 0; i &amp;lt; crossSelPickedPoints.Length;i++ )
                                    ed.WriteMessage("\n\t\t Crossing at[{0}]: {1}", i,crossSelPickedPoints[i].PointOnLine.ToString());
                            }
                            }
                            break;

                        case SelectionMethod.Window:
                            CrossingOrWindowSelectedObject windSelObj = ssItem as CrossingOrWindowSelectedObject;
                            PickPointDescriptor[] winSelPickedPoints = windSelObj.GetPickPoints();
                            if (winSelPickedPoints != null)
                            {
                                for (int i = 0; i &amp;lt; winSelPickedPoints.Length; i++)
                                    ed.WriteMessage("\n\t\t Window at[{0}]: {1}", i, winSelPickedPoints[i].PointOnLine.ToString());
                            }
                            break;&lt;BR /&gt;...&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2015 13:07:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/any-way-to-get-points-used-in-getselection/m-p/5708663#M39447</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-07-07T13:07:57Z</dc:date>
    </item>
  </channel>
</rss>

