<?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: Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or by  design? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791959#M80110</link>
    <description>It is by design. The same issue in VisualLisp/VBA/ObjectARX.</description>
    <pubDate>Sun, 15 Oct 2006 21:50:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-10-15T21:50:08Z</dc:date>
    <item>
      <title>Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or by design?</title>
      <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791957#M80108</link>
      <description>I found a intersting issue when using &lt;BR /&gt;
Editor.SelectWindowPolygon()/SelectCrossingPolygon(), that cost me quite &lt;BR /&gt;
sime time to debug my project. The problem is, the selecting polygon &lt;BR /&gt;
(crossing or window) MUST be within Acad editor's current view. That is, the &lt;BR /&gt;
polygon must be entirely viewable within the current view. If part of the &lt;BR /&gt;
polygon is out side the current view, the returned PromtSelectionResult's &lt;BR /&gt;
Status property will be "Error".&lt;BR /&gt;
&lt;BR /&gt;
Backgroud: in my project, I need to find some entities with a closed &lt;BR /&gt;
polyline. So, I used the closed polyline as selecting polygon with the &lt;BR /&gt;
SelectCrossingPolygon() method. During my code executing, the drawing's view &lt;BR /&gt;
could be zoomed/paned so that the polyline may be moved partly outside &lt;BR /&gt;
current view. The result my find entity logic was not consistent: some time &lt;BR /&gt;
it finds entities it is supposed to, some time it does not find. I &lt;BR /&gt;
eventually foudn the reason. Here is the testing code:&lt;BR /&gt;
&lt;BR /&gt;
[CommandMethod("CSTest")]&lt;BR /&gt;
public static void CrossingPolygonSelect()&lt;BR /&gt;
{&lt;BR /&gt;
    Document dwg = &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
&lt;BR /&gt;
    //Pick a polyline as selecting crossing polygon&lt;BR /&gt;
    PromptEntityResult res = dwg.Editor.GetEntity("\nPick a polyline:");&lt;BR /&gt;
    if (res.Status != PromptStatus.OK) return;&lt;BR /&gt;
&lt;BR /&gt;
    //Get selecting polyline object&lt;BR /&gt;
    Polyline pline = null;&lt;BR /&gt;
    using (Transaction tran = &lt;BR /&gt;
dwg.Database.TransactionManager.StartTransaction())&lt;BR /&gt;
    {&lt;BR /&gt;
        pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    //Get Poin3dCollection&lt;BR /&gt;
    Point3dCollection pts = new Point3dCollection();&lt;BR /&gt;
    for (int i = 0; i &amp;lt; pline.NumberOfVertices; i++)&lt;BR /&gt;
    {&lt;BR /&gt;
        Point3d pt = pline.GetPoint3dAt(i);&lt;BR /&gt;
        pts.Add(pt);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    //Get SelectionSet&lt;BR /&gt;
    PromptSelectionResult ssres = dwg.Editor.SelectCrossingPolygon(pts);&lt;BR /&gt;
&lt;BR /&gt;
    if (ssres.Status == PromptStatus.OK)&lt;BR /&gt;
        dwg.Editor.WriteMessage("\n" + ssres.Value.GetObjectIds().Length + " &lt;BR /&gt;
object(s) selected.");&lt;BR /&gt;
    else&lt;BR /&gt;
    {&lt;BR /&gt;
        switch (ssres.Status)&lt;BR /&gt;
        {&lt;BR /&gt;
            case PromptStatus.Cancel:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Cancelled.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Error:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Error."); &lt;BR /&gt;
//&amp;lt;--This error is reported&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.None:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: None.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Other:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Other.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Keyword:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Keyword.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Modeless:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Modeless.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            default:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Unknown.");&lt;BR /&gt;
                break;&lt;BR /&gt;
        }&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
To test it:&lt;BR /&gt;
&lt;BR /&gt;
1. Compile the code in a test project&lt;BR /&gt;
2. Start Acad&lt;BR /&gt;
3. "Netload" the test project&lt;BR /&gt;
4. Draw a closed polyline&lt;BR /&gt;
5. Draw a few entities with the polygon, or crossed by the polygon&lt;BR /&gt;
6. Zoom to extents to make sure entire polygon is viewable&lt;BR /&gt;
7. issue Command "CSTest", then pick the polygon. You would see at command &lt;BR /&gt;
line: "X object(s) selected."&lt;BR /&gt;
8. Zoom in so that part of the polygon is out of view&lt;BR /&gt;
9. Issed Command "CSTest", then pick the polygon. You may see at command &lt;BR /&gt;
line: "Selection Error: Error", depending on how must you zoomed in.&lt;BR /&gt;
&lt;BR /&gt;
The same behaviour is also with SelectWindowPolygon. I did not test it with &lt;BR /&gt;
SelectWindow() and SelectWindowPolygon(), but if they behaves the same, it &lt;BR /&gt;
won't supprise me.&lt;BR /&gt;
&lt;BR /&gt;
Interstingly enough, I trid Acad built-in Select with polygon command &lt;BR /&gt;
manually, that is, "Select-&amp;gt;CPolygon", and managed to move part of selecting &lt;BR /&gt;
polygon outside current view. The result was always correct, i.e. the "With &lt;BR /&gt;
View" requirement is only applies programatical selecting.&lt;BR /&gt;
&lt;BR /&gt;
Since the poor documentation of ObjectARX NET API, I could not find any &lt;BR /&gt;
information on if it is be design or it is a bug, I post the issue here.&lt;BR /&gt;
&lt;BR /&gt;
So, I work around to this iisue in my project would be to zoom to extents &lt;BR /&gt;
before using SelectCrossingPolygon()/SelectWindowPolygon(), so that the &lt;BR /&gt;
selecting polygon is shown entirely with the current view. This work around, &lt;BR /&gt;
of cause, would cause issue if the drawing size is huge: zooming in this &lt;BR /&gt;
case takes time if regen is required. Fortunately, the drawings my project &lt;BR /&gt;
deals are all fairly small in size.</description>
      <pubDate>Sun, 15 Oct 2006 17:21:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791957#M80108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-15T17:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or by  design?</title>
      <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791958#M80109</link>
      <description>Additional though:&lt;BR /&gt;
&lt;BR /&gt;
I haven't test this issue in VBA. It may be interesting to see if the same &lt;BR /&gt;
thing happens in VBA. I'll do it later today when I have time.&lt;BR /&gt;
&lt;BR /&gt;
"Norman Yuan" &lt;NOTREAL&gt; wrote in message &lt;BR /&gt;
news:5362227@discussion.autodesk.com...&lt;BR /&gt;
I found a intersting issue when using&lt;BR /&gt;
Editor.SelectWindowPolygon()/SelectCrossingPolygon(), that cost me quite&lt;BR /&gt;
sime time to debug my project. The problem is, the selecting polygon&lt;BR /&gt;
(crossing or window) MUST be within Acad editor's current view. That is, the&lt;BR /&gt;
polygon must be entirely viewable within the current view. If part of the&lt;BR /&gt;
polygon is out side the current view, the returned PromtSelectionResult's&lt;BR /&gt;
Status property will be "Error".&lt;BR /&gt;
&lt;BR /&gt;
Backgroud: in my project, I need to find some entities with a closed&lt;BR /&gt;
polyline. So, I used the closed polyline as selecting polygon with the&lt;BR /&gt;
SelectCrossingPolygon() method. During my code executing, the drawing's view&lt;BR /&gt;
could be zoomed/paned so that the polyline may be moved partly outside&lt;BR /&gt;
current view. The result my find entity logic was not consistent: some time&lt;BR /&gt;
it finds entities it is supposed to, some time it does not find. I&lt;BR /&gt;
eventually foudn the reason. Here is the testing code:&lt;BR /&gt;
&lt;BR /&gt;
[CommandMethod("CSTest")]&lt;BR /&gt;
public static void CrossingPolygonSelect()&lt;BR /&gt;
{&lt;BR /&gt;
    Document dwg =&lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
&lt;BR /&gt;
    //Pick a polyline as selecting crossing polygon&lt;BR /&gt;
    PromptEntityResult res = dwg.Editor.GetEntity("\nPick a polyline:");&lt;BR /&gt;
    if (res.Status != PromptStatus.OK) return;&lt;BR /&gt;
&lt;BR /&gt;
    //Get selecting polyline object&lt;BR /&gt;
    Polyline pline = null;&lt;BR /&gt;
    using (Transaction tran =&lt;BR /&gt;
dwg.Database.TransactionManager.StartTransaction())&lt;BR /&gt;
    {&lt;BR /&gt;
        pline = (Polyline)tran.GetObject(res.ObjectId, OpenMode.ForRead);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    //Get Poin3dCollection&lt;BR /&gt;
    Point3dCollection pts = new Point3dCollection();&lt;BR /&gt;
    for (int i = 0; i &amp;lt; pline.NumberOfVertices; i++)&lt;BR /&gt;
    {&lt;BR /&gt;
        Point3d pt = pline.GetPoint3dAt(i);&lt;BR /&gt;
        pts.Add(pt);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    //Get SelectionSet&lt;BR /&gt;
    PromptSelectionResult ssres = dwg.Editor.SelectCrossingPolygon(pts);&lt;BR /&gt;
&lt;BR /&gt;
    if (ssres.Status == PromptStatus.OK)&lt;BR /&gt;
        dwg.Editor.WriteMessage("\n" + ssres.Value.GetObjectIds().Length + "&lt;BR /&gt;
object(s) selected.");&lt;BR /&gt;
    else&lt;BR /&gt;
    {&lt;BR /&gt;
        switch (ssres.Status)&lt;BR /&gt;
        {&lt;BR /&gt;
            case PromptStatus.Cancel:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Cancelled.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Error:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Error.");&lt;BR /&gt;
//&amp;lt;--This error is reported&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.None:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: None.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Other:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Other.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Keyword:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Keyword.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            case PromptStatus.Modeless:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Modeless.");&lt;BR /&gt;
                break;&lt;BR /&gt;
            default:&lt;BR /&gt;
                dwg.Editor.WriteMessage("\nSelection Error: Unknown.");&lt;BR /&gt;
                break;&lt;BR /&gt;
        }&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
To test it:&lt;BR /&gt;
&lt;BR /&gt;
1. Compile the code in a test project&lt;BR /&gt;
2. Start Acad&lt;BR /&gt;
3. "Netload" the test project&lt;BR /&gt;
4. Draw a closed polyline&lt;BR /&gt;
5. Draw a few entities with the polygon, or crossed by the polygon&lt;BR /&gt;
6. Zoom to extents to make sure entire polygon is viewable&lt;BR /&gt;
7. issue Command "CSTest", then pick the polygon. You would see at command&lt;BR /&gt;
line: "X object(s) selected."&lt;BR /&gt;
8. Zoom in so that part of the polygon is out of view&lt;BR /&gt;
9. Issed Command "CSTest", then pick the polygon. You may see at command&lt;BR /&gt;
line: "Selection Error: Error", depending on how must you zoomed in.&lt;BR /&gt;
&lt;BR /&gt;
The same behaviour is also with SelectWindowPolygon. I did not test it with&lt;BR /&gt;
SelectWindow() and SelectWindowPolygon(), but if they behaves the same, it&lt;BR /&gt;
won't supprise me.&lt;BR /&gt;
&lt;BR /&gt;
Interstingly enough, I trid Acad built-in Select with polygon command&lt;BR /&gt;
manually, that is, "Select-&amp;gt;CPolygon", and managed to move part of selecting&lt;BR /&gt;
polygon outside current view. The result was always correct, i.e. the "With&lt;BR /&gt;
View" requirement is only applies programatical selecting.&lt;BR /&gt;
&lt;BR /&gt;
Since the poor documentation of ObjectARX NET API, I could not find any&lt;BR /&gt;
information on if it is be design or it is a bug, I post the issue here.&lt;BR /&gt;
&lt;BR /&gt;
So, I work around to this iisue in my project would be to zoom to extents&lt;BR /&gt;
before using SelectCrossingPolygon()/SelectWindowPolygon(), so that the&lt;BR /&gt;
selecting polygon is shown entirely with the current view. This work around,&lt;BR /&gt;
of cause, would cause issue if the drawing size is huge: zooming in this&lt;BR /&gt;
case takes time if regen is required. Fortunately, the drawings my project&lt;BR /&gt;
deals are all fairly small in size.&lt;/NOTREAL&gt;</description>
      <pubDate>Sun, 15 Oct 2006 17:24:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791958#M80109</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-15T17:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or by  design?</title>
      <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791959#M80110</link>
      <description>It is by design. The same issue in VisualLisp/VBA/ObjectARX.</description>
      <pubDate>Sun, 15 Oct 2006 21:50:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791959#M80110</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-15T21:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or  by design?</title>
      <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791960#M80111</link>
      <description>OK, I test it with VBA code. The result is the same: if you zoomed in to &lt;BR /&gt;
certain degree (i.e. the selecting polygon is partly outside of current &lt;BR /&gt;
view), Acad will not find entities inside th selecting polygon. But you &lt;BR /&gt;
never know exactly when or zooed in how much the SelectByPolyGon (in VBA) or &lt;BR /&gt;
SelectCrossingPolygon() (in .NET API) will fail. To garantee your code to &lt;BR /&gt;
work, you have to make sure the polygon is ENTIRELY within the current view.&lt;BR /&gt;
&lt;BR /&gt;
I probably have to admit that it is "BY DESIGN", although, if you manuall &lt;BR /&gt;
issue commad "SELECT-&amp;gt;CPolygon" and before your last pick of the polygon's &lt;BR /&gt;
point, you zoom in very much so that the large part of the selecting polygon &lt;BR /&gt;
is outside of current view, you still get CORRECT result, as you expected! &lt;BR /&gt;
So, the "BY DESIGN" trick is really designed to fool programmers, who have &lt;BR /&gt;
no way to know this "By Design" shortcomming until they were trapped in it &lt;BR /&gt;
and struggled with their code debugging.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;ALEXANDER rivilis=""&gt; wrote in message news:5362272@discussion.autodesk.com...&lt;BR /&gt;
It is by design. The same issue in VisualLisp/VBA/ObjectARX.&lt;/ALEXANDER&gt;</description>
      <pubDate>Mon, 16 Oct 2006 04:42:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791960#M80111</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-16T04:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Editor.SelectWindowPolygon()/SelectCrossingPolygon() method: bug or  by design?</title>
      <link>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791961#M80112</link>
      <description>Hi, Norman Yuan!&lt;BR /&gt;
&lt;BR /&gt;
[Sorry, skipped]&lt;BR /&gt;
NY&amp;gt; So, the "BY DESIGN" trick is really designed to&lt;BR /&gt;
NY&amp;gt; fool programmers, who have no way to know this "By Design" shortcomming&lt;BR /&gt;
NY&amp;gt; until they were trapped in it and struggled with their code debugging.&lt;BR /&gt;
[Sorry, skipped]&lt;BR /&gt;
&lt;BR /&gt;
It was "BY DESIGN" in all previous versions of AutoCAD. Remember description of&lt;BR /&gt;
that was in AutoCAD R10 or R12. You using functions - analoges of (ssget "_CP" ...) and&lt;BR /&gt;
(ssget "_WP" ...) in VisualLisp. All variants of (ssget) function except (ssget "_X" ...)&lt;BR /&gt;
working _ONLY_ with visible on screen objects.&lt;BR /&gt;
That is why SelectWindowPolygon()/SelectCrossingPolygon() also working only&lt;BR /&gt;
with visible on screen objects.&lt;BR /&gt;
&lt;BR /&gt;
Best Regards,&lt;BR /&gt;
Alexander Rivilis.</description>
      <pubDate>Mon, 16 Oct 2006 14:55:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/editor-selectwindowpolygon-selectcrossingpolygon-method-bug-or/m-p/1791961#M80112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-10-16T14:55:32Z</dc:date>
    </item>
  </channel>
</rss>

