<?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: Selections Sets and Multileader Styles in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604081#M28741</link>
    <description>&lt;P&gt;This.little code using LINQ for searching MTexts in a drawing, what goes realy fast (6MB Drawing under 1 second).&lt;/P&gt;&lt;P&gt;What you have to do is: Replace MText in MLeader.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You dont Need any foreach, which is slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://drive-cad-with-code.blogspot.de/2011/04/tips-of-using-linq-in-autocad-net.html" target="_blank"&gt;http://drive-cad-with-code.blogspot.de/2011/04/tips-of-using-linq-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://spiderinnet1.typepad.com/blog/2012/04/use-linq-to-filter-entities-in-autocad-net.html" target="_blank"&gt;http://spiderinnet1.typepad.com/blog/2012/04/use-linq-to-filter-entities-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="https://wtertinek.com/2015/05/31/linq-and-the-autocad-net-api-part-4/" target="_blank"&gt;https://wtertinek.com/2015/05/31/linq-and-the-autocad-net-api-part-4/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://through-the-interface.typepad.com/through_the_interface/2013/01/filtering-lists-of-autocad-entities-using-linq.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2013/01/filtering-lists-of-autocad-entities-using-linq.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using (Transaction m_Tr = m_DataBase.TransactionManager.StartTransaction())
{
  BlockTable m_BlockTable = (BlockTable)m_Tr.GetObject(m_DataBase.BlockTableId, OpenMode.ForRead);
  BlockTableRecord m_BlockTableRecord = 
    (BlockTableRecord)m_Tr.GetObject(m_BlockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead);

  var m_ObjectCollection = from m_ObjectId in m_BlockTableRecord.Cast&amp;lt;ObjectId&amp;gt;()
                           select new
                           {
                               m_DBObject = (DBObject)m_Tr.GetObject(m_ObjectId, OpenMode.ForRead, false)
                           };
                 
  IEnumerable&amp;lt;MText&amp;gt; m_dbMText = from m_OBJECT in m_ObjectCollection
                                 where (m_OBJECT.m_DBObject.GetType() == typeof(MText))
                                 select (MText)m_OBJECT.m_DBObject;

  m_dbMText = from m_Mtext in m_dbMText
              let Layer = m_ACADSettings.COSTextLayer
              where (m_Mtext.Layer == Layer)
              select (MText)m_Mtext;

  m_MTextList = m_dbMText.Cast&amp;lt;MText&amp;gt;().ToList();
  m_MTextList.ForEach(m_Text =&amp;gt; m_ObjectIdList.Add(m_Text.ObjectId));
  m_Tr.Commit();
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2017 10:15:09 GMT</pubDate>
    <dc:creator>Juergen_Becker</dc:creator>
    <dc:date>2017-12-07T10:15:09Z</dc:date>
    <item>
      <title>Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7597389#M28735</link>
      <description>&lt;P&gt;Trying to get back into .NET programming and I need to be able to have a user select existing a&amp;nbsp;mleader and&amp;nbsp;based on the mleaderstyle.add it to a selection set in C#.&amp;nbsp; So far, I can find filter based on MLEADER, but I cannot figure out how to further filter by mleaderstyle.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help get me pointed in the right direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 13:58:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7597389#M28735</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2017-12-05T13:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7597607#M28736</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;As far as I know, to get a selection set of Multileader style filtered is something that is not possible but to iterate through the selection set is the working process for this task I believe.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Good luck.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:13:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7597607#M28736</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2017-12-05T15:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7600747#M28737</link>
      <description>&lt;P&gt;So, I cannot drill in and filter my selection set by multileader style.&amp;nbsp; However, as all of the multileaders I am going to work with MUST be located on a layer with a specific suffix I can further isolate the initial selection set to the specific multileaders I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next issue is that I need to iterate through the selection set to make sure that it has MText.&amp;nbsp; If not, then go to the next item in the selection set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it does, then I need to read the first line of that MText content, get the layername, get the leader start and end points and create a new MultiLeader on a different layer with only the first line of text in the MText using a different Multileader style using the same start and end points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggling with how to drill into the object to first make sure it has MText and then to read the MText content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All help is greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 12:33:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7600747#M28737</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2017-12-06T12:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7602377#M28738</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Its been for a while since I have worked with C# but your aim of codes seems to be easy enough, so here is my attempt and basic codes for you to start with.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public static void Test()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                TypedValue[] tv = { new TypedValue(0, "MULTILEADER") };
                PromptSelectionResult sel = ed.GetSelection(new SelectionFilter(tv));
                if (sel.Status == PromptStatus.OK)
                {
                    foreach (ObjectId obj in sel.Value.GetObjectIds())
                    {
                        MLeader mld = (MLeader)tr.GetObject(obj, OpenMode.ForRead);
                        MLeaderStyle mls = (MLeaderStyle)tr.GetObject(mld.MLeaderStyle, OpenMode.ForRead);
                        if (mls.Name == "Test" &amp;amp;&amp;amp; mld.MText.Contents.Contains("\\P"))
                        {
                            ed.WriteMessage("\nMleader style object &amp;lt;Test&amp;gt; was selected and its has more than one line of texts");
                        }
                    }
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 19:18:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7602377#M28738</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2017-12-06T19:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7602618#M28739</link>
      <description>&lt;P&gt;Thanks!! I am&amp;nbsp;beginning to make some progress now.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 20:28:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7602618#M28739</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2017-12-06T20:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7603529#M28740</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;You are welcome.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Good luck.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 04:49:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7603529#M28740</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2017-12-07T04:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604081#M28741</link>
      <description>&lt;P&gt;This.little code using LINQ for searching MTexts in a drawing, what goes realy fast (6MB Drawing under 1 second).&lt;/P&gt;&lt;P&gt;What you have to do is: Replace MText in MLeader.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You dont Need any foreach, which is slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://drive-cad-with-code.blogspot.de/2011/04/tips-of-using-linq-in-autocad-net.html" target="_blank"&gt;http://drive-cad-with-code.blogspot.de/2011/04/tips-of-using-linq-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://spiderinnet1.typepad.com/blog/2012/04/use-linq-to-filter-entities-in-autocad-net.html" target="_blank"&gt;http://spiderinnet1.typepad.com/blog/2012/04/use-linq-to-filter-entities-in-autocad-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="https://wtertinek.com/2015/05/31/linq-and-the-autocad-net-api-part-4/" target="_blank"&gt;https://wtertinek.com/2015/05/31/linq-and-the-autocad-net-api-part-4/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="More about Linq" href="http://through-the-interface.typepad.com/through_the_interface/2013/01/filtering-lists-of-autocad-entities-using-linq.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2013/01/filtering-lists-of-autocad-entities-using-linq.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using (Transaction m_Tr = m_DataBase.TransactionManager.StartTransaction())
{
  BlockTable m_BlockTable = (BlockTable)m_Tr.GetObject(m_DataBase.BlockTableId, OpenMode.ForRead);
  BlockTableRecord m_BlockTableRecord = 
    (BlockTableRecord)m_Tr.GetObject(m_BlockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead);

  var m_ObjectCollection = from m_ObjectId in m_BlockTableRecord.Cast&amp;lt;ObjectId&amp;gt;()
                           select new
                           {
                               m_DBObject = (DBObject)m_Tr.GetObject(m_ObjectId, OpenMode.ForRead, false)
                           };
                 
  IEnumerable&amp;lt;MText&amp;gt; m_dbMText = from m_OBJECT in m_ObjectCollection
                                 where (m_OBJECT.m_DBObject.GetType() == typeof(MText))
                                 select (MText)m_OBJECT.m_DBObject;

  m_dbMText = from m_Mtext in m_dbMText
              let Layer = m_ACADSettings.COSTextLayer
              where (m_Mtext.Layer == Layer)
              select (MText)m_Mtext;

  m_MTextList = m_dbMText.Cast&amp;lt;MText&amp;gt;().ToList();
  m_MTextList.ForEach(m_Text =&amp;gt; m_ObjectIdList.Add(m_Text.ObjectId));
  m_Tr.Commit();
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:15:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604081#M28741</guid>
      <dc:creator>Juergen_Becker</dc:creator>
      <dc:date>2017-12-07T10:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604102#M28742</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;I guess you misunderstood what the OP wants.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="georgia,palatino" size="3"&gt;They want to search for a specific Mleader Style Name and once found, then search its related Mtext string.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:24:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604102#M28742</guid>
      <dc:creator>_Tharwat</dc:creator>
      <dc:date>2017-12-07T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selections Sets and Multileader Styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604129#M28743</link>
      <description>&lt;P&gt;No, I think, I don't misunderstand it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What about this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using (Transaction m_Tr = m_DataBase.TransactionManager.StartTransaction())
{
  BlockTable m_BlockTable = (BlockTable)m_Tr.GetObject(m_DataBase.BlockTableId, OpenMode.ForRead);
  BlockTableRecord m_BlockTableRecord =
      (BlockTableRecord)m_Tr.GetObject(m_BlockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead);

  var m_ObjectCollection = from m_ObjectId in m_BlockTableRecord.Cast&amp;lt;ObjectId&amp;gt;()
                           select new
                           {
                               m_DBObject = (DBObject)m_Tr.GetObject(m_ObjectId, OpenMode.ForRead, false)
                           };

  IEnumerable&amp;lt;MLeader&amp;gt; m_dbMLeader = from m_OBJECT in m_ObjectCollection
                                     where (m_OBJECT.m_DBObject.GetType() == typeof(MLeader))
                                     select (MLeader)m_OBJECT.m_DBObject;

  m_dbMLeader = from m_MLeader in m_dbMLeader
                let StyleID = m_LeaderStyle.ObjectId
                where (m_MLeader.MLeaderStyle == StyleID)
                select (MLeader)m_MLeader;&lt;BR /&gt;
  List&amp;lt;MLeader&amp;gt; m_MLeaderList = null;
  m_MLeaderList = m_dbMLeader.Cast&amp;lt;MLeader&amp;gt;().ToList();
  m_MLeaderList.ForEach(m_MLeader =&amp;gt; m_ObjectIdList.Add(m_MLeader.ObjectId));
  m_Tr.Commit();
}&lt;/PRE&gt;&lt;P&gt;This code searching for MLeaders with specific Style.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;m_dbMLeader = from m_MLeader in m_dbMLeader
                let StyleID = m_LeaderStyle.ObjectId
                where (m_MLeader.MLeaderStyle == StyleID)
                select (MLeader)m_MLeader;&lt;/PRE&gt;&lt;P&gt;First you have to define what Style you want (m_LeaderStyle). Please Change the Where-Condition according to your need (Text etc.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 10:40:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selections-sets-and-multileader-styles/m-p/7604129#M28743</guid>
      <dc:creator>Juergen_Becker</dc:creator>
      <dc:date>2017-12-07T10:40:30Z</dc:date>
    </item>
  </channel>
</rss>

