<?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: strange behavior in creating selectionset in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11207318#M12769</link>
    <description>&lt;P&gt;many thanks sir!&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jun 2022 10:46:42 GMT</pubDate>
    <dc:creator>a.kouchakzadeh</dc:creator>
    <dc:date>2022-06-01T10:46:42Z</dc:date>
    <item>
      <title>strange behavior in creating selectionset</title>
      <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205237#M12765</link>
      <description>&lt;P&gt;I have noticed a strange behavior while creating a selection set. my program gets two corners of a rectangle to create a window selectionset, then passes the two points to another method to create the selection set. but the user has to pick an object fist, so the program could find out whats the type of the object to make its filter, also to find out the layer that it has to filter.&lt;/P&gt;&lt;P&gt;whats strange is, this is the window that Im selecting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akouchakzadeh_0-1654010384163.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1074223i912F0C64B67B151A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akouchakzadeh_0-1654010384163.png" alt="akouchakzadeh_0-1654010384163.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;then I zoom in to pick a block object,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akouchakzadeh_1-1654010444166.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1074225i5FD8BA059C857A30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akouchakzadeh_1-1654010444166.png" alt="akouchakzadeh_1-1654010444166.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;surprisingly, the operation which in my case is trimming the lines inside the blocks, only trims the lines which are seen on the zoomed screen! I even added a watch on my selection set and noticed that&lt;/P&gt;&lt;P&gt;var selectionResult =&amp;nbsp; ed.SelectWindow(firstCorner, secondCorner,selectionFilter) does not care about the specified corners and instead uses the zoomed window cordination instead!&lt;/P&gt;&lt;P&gt;I think, I had the same issue with VBA?! I'm not sure though.&lt;/P&gt;&lt;P&gt;how can I fix this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static SelectionSet CreateSelectionSet(Document doc, string objectType
            , List&amp;lt;Point3d&amp;gt; pointList, Type type)
        {
            var ed = doc.Editor;
            var db = doc.Database;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                Entity entity = null;
                string objectLayer = "SPRKVIEW";
                var strType = type.ToString().Substring(34, type.ToString().Length-34);
                try
                {
                    if ((objectType.ToUpper()=="LINE" || objectType.ToUpper()=="INSERT"))
                    {
                        var peo = new PromptEntityOptions("\nSelect a " + strType +
                            " represting the desired object");
                        peo.SetRejectMessage("\nNot a valid Object! Select a " + strType);
                        peo.AddAllowedClass(type , true);
                        peo.AllowNone=true;
                        peo.AllowObjectOnLockedLayer=true;
                        var res = ed.GetEntity(peo);

                        entity = tr.GetObject(res.ObjectId, OpenMode.ForRead) as Entity;
                        if (res.Status != PromptStatus.OK)
                        {
                            tr.Abort();
                            return null;
                        }
                        objectLayer = entity.Layer;
                    }

                    var firstCorner = pointList[0];
                    var secondCorner = pointList[1];
                    var filterValue = new TypedValue[2];
                    filterValue.SetValue(new TypedValue((int)DxfCode.Start, objectType), 0);
                    filterValue.SetValue(new TypedValue((int)DxfCode.LayerName, objectLayer), 1);

                    var selectionFilter = new SelectionFilter(filterValue);
                    var selectionResult = ed.SelectWindow(firstCorner, secondCorner, selectionFilter);
                    var selectionSet = selectionResult.Value as SelectionSet;

                    if (selectionSet!=null)
                    {
                        tr.Commit();
                        return selectionSet;
                    }
                    else
                    {
                        tr.Abort();
                        return null;
                    }
                    
                }
                catch (System.Exception ex)
                {
                    Application.ShowAlertDialog("Error occured: " + ex.Message);
                    return null;
                }
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 31 May 2022 15:44:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205237#M12765</guid>
      <dc:creator>a.kouchakzadeh</dc:creator>
      <dc:date>2022-05-31T15:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior in creating selectionset</title>
      <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205416#M12766</link>
      <description>&lt;P&gt;Yes, what you observed in both VBA and .NET API is the limitation of using Editor.Select[Crossing/Polygon/Window]() (.NET) and AcadSelectionSet.Select(acSelectionSetWindow/Crossing/Polygon, ...) methods: the selecting window/polygon must be within the current view. So, before you call Edotor.SelectWindow(), you need to make sure the window is visibly with in the current view. Usually, you zoom out to the window/polygon before calling Editor.SelectWindow[Polygon]().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 16:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205416#M12766</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-05-31T16:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior in creating selectionset</title>
      <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205485#M12767</link>
      <description>&lt;P&gt;thanks for your reply Mr. Yuan, but now Im stuck with the zoom function. am I doing some thing wrong or is it really this complicated?&lt;/P&gt;&lt;P&gt;Giles&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/net/is-selectionwindow-went-wrong-or-something-autocad-net-c/td-p/6751210" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;in this post&amp;nbsp;&lt;/STRONG&gt;&lt;/A&gt;uses acadApp.ZoomExtents() but its not working for me?&lt;/P&gt;&lt;P&gt;when I type acadApp... I cant see the intellisense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to Zoomwindow and then zoom previous.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 16:55:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205485#M12767</guid>
      <dc:creator>a.kouchakzadeh</dc:creator>
      <dc:date>2022-05-31T16:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior in creating selectionset</title>
      <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205560#M12768</link>
      <description>&lt;P&gt;Because it was calling AutoCAD COM API with late binding (dynamic in C#), thus not intellisense.&lt;/P&gt;
&lt;P&gt;to call COM API's ZoomWindow(), you simply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dynamic cadApp=Application.AcadApplication&lt;/P&gt;
&lt;P&gt;var double[] point1=new[]{0.0,0.0,0.0}; // use your own winodow's lowerleft corner and upperright corner&lt;/P&gt;
&lt;P&gt;var double[] point2=new[]{100,100,0};&lt;/P&gt;
&lt;P&gt;cadApp.ZoomWindow(point1, point2);&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 17:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11205560#M12768</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-05-31T17:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior in creating selectionset</title>
      <link>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11207318#M12769</link>
      <description>&lt;P&gt;many thanks sir!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 10:46:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/strange-behavior-in-creating-selectionset/m-p/11207318#M12769</guid>
      <dc:creator>a.kouchakzadeh</dc:creator>
      <dc:date>2022-06-01T10:46:42Z</dc:date>
    </item>
  </channel>
</rss>

