<?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 Can I do normal window selection without the TypedValue, DXFCode crap? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923268#M32429</link>
    <description>&lt;P&gt;Hi Guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm tryiing to do a little application and for that I would like to make a normal window selection (the green/blue type) and get different object types from this selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So windowing on lot of objects and get only blocks or lines (for example lines, 2dpolys and 3d polys together) and etc. This is what a want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not an expert, I found a dxf code way, here it is, This is working, but I would have a more elegant way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static ObjectIdCollection promptForPointsByWindow()
        {
            //actual ACAD doc and editor
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            //Az Editor beállítása
            Editor acEd = acDoc.Editor;

            //defining the object filter
            TypedValue[] TypVal = new TypedValue[1];
            TypVal.SetValue(new TypedValue((int)DxfCode.Start, "POINT"), 0);

            // filter to the selset
            SelectionFilter SelFilt = new SelectionFilter(TypVal);

            //user input get selection
            PromptSelectionResult pSelRes = acEd.GetSelection(SelFilt);

            SelectionSet selSet = pSelRes.Value;

             ObjectIdCollection points = new ObjectIdCollection(selSet.GetObjectIds());

            //write out count()
            Application.ShowAlertDialog("A kiválasztott pontok száma: " + selSet.Count.ToString());

            return points;

        }&lt;/PRE&gt;&lt;P&gt;Do you have a normal easy way to do it? Like AllowedTypes = .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;THX&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 12:26:03 GMT</pubDate>
    <dc:creator>vroom74</dc:creator>
    <dc:date>2017-03-06T12:26:03Z</dc:date>
    <item>
      <title>Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923268#M32429</link>
      <description>&lt;P&gt;Hi Guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm tryiing to do a little application and for that I would like to make a normal window selection (the green/blue type) and get different object types from this selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So windowing on lot of objects and get only blocks or lines (for example lines, 2dpolys and 3d polys together) and etc. This is what a want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not an expert, I found a dxf code way, here it is, This is working, but I would have a more elegant way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static ObjectIdCollection promptForPointsByWindow()
        {
            //actual ACAD doc and editor
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            //Az Editor beállítása
            Editor acEd = acDoc.Editor;

            //defining the object filter
            TypedValue[] TypVal = new TypedValue[1];
            TypVal.SetValue(new TypedValue((int)DxfCode.Start, "POINT"), 0);

            // filter to the selset
            SelectionFilter SelFilt = new SelectionFilter(TypVal);

            //user input get selection
            PromptSelectionResult pSelRes = acEd.GetSelection(SelFilt);

            SelectionSet selSet = pSelRes.Value;

             ObjectIdCollection points = new ObjectIdCollection(selSet.GetObjectIds());

            //write out count()
            Application.ShowAlertDialog("A kiválasztott pontok száma: " + selSet.Count.ToString());

            return points;

        }&lt;/PRE&gt;&lt;P&gt;Do you have a normal easy way to do it? Like AllowedTypes = .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;THX&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 12:26:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923268#M32429</guid>
      <dc:creator>vroom74</dc:creator>
      <dc:date>2017-03-06T12:26:03Z</dc:date>
    </item>
    <item>
      <title>Re : Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923419#M32430</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the way &lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-D9FB23AE-D853-4D00-A910-4F66FCC4607A" target="_blank"&gt;selection filters&lt;/A&gt; work and it's not crap because it allows much more than only fiter by entity type.&lt;/P&gt;
&lt;P&gt;You can see an example and some explanations in &lt;A href="https://forums.autodesk.com/t5/net/total-length-of-selected-objects/td-p/6916755" target="_blank"&gt;this thread&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way should be handling the Editor.SelectionAdded event.&lt;/P&gt;
&lt;P&gt;Here's an exemple to filter measurable curves as in the upper example (arc, circle, ellipse, polyline (2d or 3d) and splines).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            var allowed = new HashSet&amp;lt;string&amp;gt;
            {
                "AcDbArc",
                "AcDbCircle",
                "AcDbEllipse",
                "AcDbLine",
                "AcDbPolyline",
                "AcDb2dPolyline",
                "AcDb3dPolyline",
                "AcDbSpline"
            };

            SelectionAddedEventHandler filter = (_, e) =&amp;gt;
            {
                var objs = e.AddedObjects;
                for (int i = 0; i &amp;lt; objs.Count; i++)
                {
                    if (!allowed.Contains(objs[i].ObjectId.ObjectClass.Name))
                        e.Remove(i);
                }
            };

            ed.SelectionAdded += filter;
            var selection = ed.GetSelection();
            ed.SelectionAdded -= filter;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 13:36:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923419#M32430</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-06T13:36:40Z</dc:date>
    </item>
    <item>
      <title>Re : Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923498#M32431</link>
      <description>&lt;P&gt;Thank you for you quick answer. Its working. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, I accepted the dxfCode way based on your TotalLengthOfSelectedObjects solution, but I'll try event based method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a really beginner at programming, Sometimes i found autocad.net system very complicated and not logical (for me) &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BIG THANK YOU AGAIN&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 14:07:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6923498#M32431</guid>
      <dc:creator>vroom74</dc:creator>
      <dc:date>2017-03-06T14:07:40Z</dc:date>
    </item>
    <item>
      <title>Re : Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6924831#M32432</link>
      <description>&lt;P&gt;you can try force casting it like this;&lt;BR /&gt;&lt;BR /&gt;Lets say you want to catch polyline;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;foreach (entity ent in selection)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Polyline poly = ent as Polyline;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (poly != 0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do something.... (in your case add to new selection set)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can then create your own selection set based on your criteria.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:02:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6924831#M32432</guid>
      <dc:creator>5thSth</dc:creator>
      <dc:date>2017-03-06T21:02:48Z</dc:date>
    </item>
    <item>
      <title>Re : Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6924986#M32433</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3079209"&gt;@5thSth&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This won't work:&lt;/P&gt;
&lt;PRE&gt;if (poly != 0)&lt;/PRE&gt;
&lt;P&gt;It should have been: &lt;/P&gt;
&lt;PRE&gt;if (poly != null)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, it's much more efficient to test the ObjectId.ObjectClass before opening the ObjectId:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;If (id.ObjectClass == RXObject.GetClass(typeof(Polyline)))
{
    var poly = (Polyline)tr.GetObject (id, OpenMode.ForRead);
    // do something with the polyline
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:02:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6924986#M32433</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-06T22:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6929991#M32434</link>
      <description>Hi _gile.&lt;BR /&gt;&lt;BR /&gt;Your example that uses an equality comparison is somewhat different from using the C# 'as' operator on the managed wrapper, which will succeed with derived types as well. To do the equivalent with RXClass you would use the IsDerivedFrom() member.&lt;BR /&gt;&lt;BR /&gt;Of course, it all depends on if you want to include derived types or not.</description>
      <pubDate>Wed, 08 Mar 2017 14:06:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6929991#M32434</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-03-08T14:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6930225#M32435</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;You are right, to mimic the selection filter, I should have written:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;if (id.ObjectClass.DxfName == "LWPOLYLINE")&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class=""&gt;which also filters any custom entities that are derived from Polyline.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;But, in my opinion, the main difference (and this is what I wanted to point out) is that testing the ObjectId type avoids opening the DBObject if it is not of the required type.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 14:52:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6930225#M32435</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-08T14:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6931655#M32436</link>
      <description>&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Yes, and IsDerivedFrom() also doesn't need a managed wrapper. It also has an additional benefit of being able to match derived custom objects that don't have managed wrappers, which the C# 'as' operator will not match.</description>
      <pubDate>Wed, 08 Mar 2017 19:26:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6931655#M32436</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-03-08T19:26:10Z</dc:date>
    </item>
    <item>
      <title>Re : Can I do normal window selection without the TypedValue, DXFCode crap?</title>
      <link>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6940293#M32437</link>
      <description>&lt;P&gt;thanks &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;for the RXObject approach. so far took it for granted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you and Kean have been priceless for me when it comes to learning .net and c#.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2017 14:15:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/can-i-do-normal-window-selection-without-the-typedvalue-dxfcode/m-p/6940293#M32437</guid>
      <dc:creator>5thSth</dc:creator>
      <dc:date>2017-03-12T14:15:50Z</dc:date>
    </item>
  </channel>
</rss>

