<?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: how to reshuffle by Y axis and will group or arranged by X axis in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7871475#M26871</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3144830"&gt;@kite15&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;needs to cast the &lt;STRONG&gt;var texts&lt;/STRONG&gt; as &lt;STRONG&gt;SelectionSet&lt;/STRONG&gt; ????&amp;nbsp;Kindly, suggest....&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, this snippet is part of my testing command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use this more generic extension method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    public static class DBTextExtension
    {
        public static IEnumerable&amp;lt;DBText&amp;gt; SortByColumn(this IEnumerable&amp;lt;DBText&amp;gt; source, double columnWidth)
        {
            return source
                .OrderBy(txt =&amp;gt; Math.Round(txt.Position.X / columnWidth))
                .ThenByDescending(txt =&amp;gt; txt.Position.Y);
        }
    }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 12:58:21 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-03-21T12:58:21Z</dc:date>
    <item>
      <title>how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7864784#M26863</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have work on DBText and&amp;nbsp;MText objects and collected some information to a list. Required to reshuffle the collected list as only Y axis Point3D value.&lt;/P&gt;&lt;P&gt;Can any one help me to suggest how to reshuffle and will group by X axis. Please, see the attached snap for better understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my present code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            List&amp;lt;MyMtxtData&amp;gt; myMtexts = new List&amp;lt;MyMtxtData&amp;gt;();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in sset.GetObjectIds())
                {
                    DBObject obj = (DBObject)tr.GetObject(id, OpenMode.ForRead) as DBObject;
                    MyMtxtData myMtext = new MyMtxtData() { MyMtID = id };
                    if (obj.GetRXClass().DxfName == "MTEXT")
                    {
                        MText Mt = (MText)obj as MText;
                        myMtext.MyMtLocation = Mt.Location;
                        myMtext.MyMtContain = Mt.Contents;
                        myMtext.MyMtHgt = Mt.TextHeight;
                        myMtext.MyMtRot = Mt.Rotation;
                    }
                    else if (obj.GetRXClass().DxfName == "TEXT")
                    {
                        DBText Dt = (DBText)obj as DBText;
                        myMtext.MyMtLocation = Dt.Position;
                        myMtext.MyMtContain = Dt.TextString;
                        myMtext.MyMtHgt = Dt.Height;
                        myMtext.MyMtRot = Dt.Rotation;
                    }
                    myMtexts.Add(myMtext);
                }
                //myMtexts = myMtexts.OrderBy(x =&amp;gt; x.MyMtLocation.Y).ThenBy(x =&amp;gt; x.MyMtLocation.X).ToList();
                myMtexts = myMtexts.OrderByDescending(x =&amp;gt; x.MyMtLocation.Y).ToList();
                tr.Dispose();
            }&lt;/PRE&gt;&lt;P&gt;Please, Help !!&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:01:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7864784#M26863</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-03-19T13:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865040#M26864</link>
      <description>&lt;P&gt;Why not try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var result = myMtexts.GroupBy(text =&amp;gt; Math.Round(text.MyMtLocation.X / 50)).OrderBy(group =&amp;gt; group.Key).Select(group =&amp;gt; group.OrderByDescending(text =&amp;gt; text.MyMtLocation.X));

&lt;/PRE&gt;&lt;P&gt;It groups everything in the x direction every 50 units, and then orders descending by Y.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Warning: Untested code)&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:26:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865040#M26864</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2018-03-19T14:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865053#M26865</link>
      <description>&lt;P&gt;If you want a single list over all items in that order, then use the LINQ SelectMany() method on the end&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:30:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865053#M26865</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2018-03-19T14:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865916#M26866</link>
      <description>&lt;P&gt;Your problem is a bit difficult to solve in the form you present it because the width of each blue box is not clearly defined.&amp;nbsp;You have to determine what the allowed ranges of the x-coordinates (either the insertion points or the min/max points of the bounding boxes) are for each grouping.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you've done that, OrderBy() or OrderByDescending() and GroupBy() should be all you need to solve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3144830"&gt;@kite15&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have work on DBText and&amp;nbsp;MText objects and collected some information to a list. Required to reshuffle the collected list as only Y axis Point3D value.&lt;/P&gt;&lt;P&gt;Can any one help me to suggest how to reshuffle and will group by X axis. Please, see the attached snap for better understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my present code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            List&amp;lt;MyMtxtData&amp;gt; myMtexts = new List&amp;lt;MyMtxtData&amp;gt;();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in sset.GetObjectIds())
                {
                    DBObject obj = (DBObject)tr.GetObject(id, OpenMode.ForRead) as DBObject;
                    MyMtxtData myMtext = new MyMtxtData() { MyMtID = id };
                    if (obj.GetRXClass().DxfName == "MTEXT")
                    {
                        MText Mt = (MText)obj as MText;
                        myMtext.MyMtLocation = Mt.Location;
                        myMtext.MyMtContain = Mt.Contents;
                        myMtext.MyMtHgt = Mt.TextHeight;
                        myMtext.MyMtRot = Mt.Rotation;
                    }
                    else if (obj.GetRXClass().DxfName == "TEXT")
                    {
                        DBText Dt = (DBText)obj as DBText;
                        myMtext.MyMtLocation = Dt.Position;
                        myMtext.MyMtContain = Dt.TextString;
                        myMtext.MyMtHgt = Dt.Height;
                        myMtext.MyMtRot = Dt.Rotation;
                    }
                    myMtexts.Add(myMtext);
                }
                //myMtexts = myMtexts.OrderBy(x =&amp;gt; x.MyMtLocation.Y).ThenBy(x =&amp;gt; x.MyMtLocation.X).ToList();
                myMtexts = myMtexts.OrderByDescending(x =&amp;gt; x.MyMtLocation.Y).ToList();
                tr.Dispose();
            }&lt;/PRE&gt;&lt;P&gt;Please, Help !!&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 18:30:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7865916#M26866</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-03-19T18:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7866493#M26867</link>
      <description>&lt;PRE&gt;var result = myMtexts.GroupBy(text =&amp;gt; Math.Round(text.MyMtLocation.X / 50)).OrderBy(group =&amp;gt; group.Key).Select(group =&amp;gt; group.OrderByDescending(text =&amp;gt; text.MyMtLocation.Y));&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ooops! order by descending use the Y coordinate not the x.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 22:00:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7866493#M26867</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2018-03-19T22:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7870861#M26868</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try with the provided codes. No luck!!&lt;/P&gt;&lt;P&gt;Have any suggestion.......&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 10:04:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7870861#M26868</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-03-21T10:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7870999#M26869</link>
      <description>&lt;P&gt;As &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt; said, you have to define the 'column width' so that you can adjust the rounding factor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this (it only deals with DBText):&lt;/P&gt;
&lt;PRE&gt;var texts = selectionResult.Value
    .Cast&amp;lt;SelectedObject&amp;gt;()
    .Select(so =&amp;gt; (DBText)tr.GetObject(so.ObjectId, OpenMode.ForWrite))
    .OrderBy(txt =&amp;gt; Math.Round(txt.Position.X / 50.0)) // &amp;lt;- change this to suit your needs
    .ThenByDescending(txt =&amp;gt; txt.Position.Y);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 10:54:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7870999#M26869</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-03-21T10:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7871298#M26870</link>
      <description>&lt;P&gt;Hi _gile,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Checked [by debugging], its works as expected. Can you please, guide once more...&lt;/P&gt;&lt;P&gt;needs to cast the &lt;STRONG&gt;var texts&lt;/STRONG&gt; as &lt;STRONG&gt;SelectionSet&lt;/STRONG&gt; ????&amp;nbsp;Kindly, suggest....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var texts = selectionResult.Value
    .Cast&amp;lt;SelectedObject&amp;gt;()
    .Select(so =&amp;gt; (DBText)tr.GetObject(so.ObjectId, OpenMode.ForWrite))
    .OrderBy(txt =&amp;gt; Math.Round(txt.Position.X / 50.0)) // &amp;lt;- change this to suit your needs
    .ThenByDescending(txt =&amp;gt; txt.Position.Y);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks again....&lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://forums.autodesk.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 12:15:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7871298#M26870</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-03-21T12:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7871475#M26871</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3144830"&gt;@kite15&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;needs to cast the &lt;STRONG&gt;var texts&lt;/STRONG&gt; as &lt;STRONG&gt;SelectionSet&lt;/STRONG&gt; ????&amp;nbsp;Kindly, suggest....&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, this snippet is part of my testing command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use this more generic extension method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    public static class DBTextExtension
    {
        public static IEnumerable&amp;lt;DBText&amp;gt; SortByColumn(this IEnumerable&amp;lt;DBText&amp;gt; source, double columnWidth)
        {
            return source
                .OrderBy(txt =&amp;gt; Math.Round(txt.Position.X / columnWidth))
                .ThenByDescending(txt =&amp;gt; txt.Position.Y);
        }
    }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 12:58:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7871475#M26871</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-03-21T12:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to reshuffle by Y axis and will group or arranged by X axis</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7873909#M26872</link>
      <description>&lt;P&gt;Thank you very much its works&amp;nbsp;fine....&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 05:11:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-reshuffle-by-y-axis-and-will-group-or-arranged-by-x-axis/m-p/7873909#M26872</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-03-22T05:11:23Z</dc:date>
    </item>
  </channel>
</rss>

