<?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 help: get layerIds collection for LayerFilter and LayerGroup in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/help-get-layerids-collection-for-layerfilter-and-layergroup/m-p/4584513#M47134</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I´m trying to get layers Id Collection for LayerFilter( properties filter in LayerManager) and LayerGroup (group filter in LayerManager too).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LayerGroup has method "LayerIds()" to get collection but I can´t use because debugger say me that it is a LayerFilter when it is &amp;nbsp;really a LayerGroup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; public static List&amp;lt;Filtros_Capas&amp;gt; Get_FiltrosCapas()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            // List the nested(anidadas) layer filters. NeestedFilters siginifca que hay filtros dentro de otros filtros.
            List&amp;lt;toolsC3D.Filtros_Capas&amp;gt; listaFiltros = new List&amp;lt;toolsC3D.Filtros_Capas&amp;gt;();   // instancia de la nueva lista
            Filtros_Capas aBobj = default(Filtros_Capas);

            LayerFilterTree lft = db.LayerFilters; //esquema en arbol de la lista de filtros.
            Autodesk.AutoCAD.LayerManager.LayerFilterCollection lfc = db.LayerFilters.Root.NestedFilters;

      
            for (int i = 0; i &amp;lt;= lfc.Count - 1; i++)
            {
                if (lfc[i].FilterExpression == "")
                {
                    if (lfc[i].IsIdFilter == true)
                    {
                      

                            aBobj.Name = lfc[i].Name;
                            aBobj.Count = lfc[i].&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;LayerIds&lt;/FONT&gt;&lt;/STRONG&gt;.Count;

                            listaFiltros.Add(aBobj);
                        
                    }
                }

                else
                {

                }
            }
            
            return listaFiltros;

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I don´t know &amp;nbsp;how to differentiate when filter is LayerFilter or LayerGroup. &amp;nbsp;I use:&lt;/P&gt;&lt;PRE&gt;FilterExpression == ""&lt;/PRE&gt;&lt;P&gt;and I take for granted &amp;nbsp;that &amp;nbsp;filter is LayerGroup, but it isn´t quite right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to do this, but it doesn´t work.&lt;/P&gt;&lt;PRE&gt;  foreach(LayerGroup filter in lfc)
                    {
                      

                            aBobj.Name = filter.Name;
                              aBobj.Count=filter.LayerIds.Count;

                            listaFiltros.Add(aBobj);
                        
                    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get id layers collection for LayerFilter and LayerGroup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Nov 2013 15:39:51 GMT</pubDate>
    <dc:creator>joantopo</dc:creator>
    <dc:date>2013-11-01T15:39:51Z</dc:date>
    <item>
      <title>help: get layerIds collection for LayerFilter and LayerGroup</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-layerids-collection-for-layerfilter-and-layergroup/m-p/4584513#M47134</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I´m trying to get layers Id Collection for LayerFilter( properties filter in LayerManager) and LayerGroup (group filter in LayerManager too).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LayerGroup has method "LayerIds()" to get collection but I can´t use because debugger say me that it is a LayerFilter when it is &amp;nbsp;really a LayerGroup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; public static List&amp;lt;Filtros_Capas&amp;gt; Get_FiltrosCapas()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            // List the nested(anidadas) layer filters. NeestedFilters siginifca que hay filtros dentro de otros filtros.
            List&amp;lt;toolsC3D.Filtros_Capas&amp;gt; listaFiltros = new List&amp;lt;toolsC3D.Filtros_Capas&amp;gt;();   // instancia de la nueva lista
            Filtros_Capas aBobj = default(Filtros_Capas);

            LayerFilterTree lft = db.LayerFilters; //esquema en arbol de la lista de filtros.
            Autodesk.AutoCAD.LayerManager.LayerFilterCollection lfc = db.LayerFilters.Root.NestedFilters;

      
            for (int i = 0; i &amp;lt;= lfc.Count - 1; i++)
            {
                if (lfc[i].FilterExpression == "")
                {
                    if (lfc[i].IsIdFilter == true)
                    {
                      

                            aBobj.Name = lfc[i].Name;
                            aBobj.Count = lfc[i].&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;LayerIds&lt;/FONT&gt;&lt;/STRONG&gt;.Count;

                            listaFiltros.Add(aBobj);
                        
                    }
                }

                else
                {

                }
            }
            
            return listaFiltros;

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I don´t know &amp;nbsp;how to differentiate when filter is LayerFilter or LayerGroup. &amp;nbsp;I use:&lt;/P&gt;&lt;PRE&gt;FilterExpression == ""&lt;/PRE&gt;&lt;P&gt;and I take for granted &amp;nbsp;that &amp;nbsp;filter is LayerGroup, but it isn´t quite right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to do this, but it doesn´t work.&lt;/P&gt;&lt;PRE&gt;  foreach(LayerGroup filter in lfc)
                    {
                      

                            aBobj.Name = filter.Name;
                              aBobj.Count=filter.LayerIds.Count;

                            listaFiltros.Add(aBobj);
                        
                    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get id layers collection for LayerFilter and LayerGroup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2013 15:39:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-layerids-collection-for-layerfilter-and-layergroup/m-p/4584513#M47134</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2013-11-01T15:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: help: get layerIds collection for LayerFilter and LayerGroup</title>
      <link>https://forums.autodesk.com/t5/net-forum/help-get-layerids-collection-for-layerfilter-and-layergroup/m-p/4584721#M47135</link>
      <description>&lt;P&gt;Finally, I have made this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used bool method (.Filter) to check if each layer in LayerTable is included in selected filter(with filter´s Name).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created two functions that get two list, one for list of name layerfilters, and other to Idlayers inclued in filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   public static List&amp;lt;Filtros_Capas&amp;gt; Get_FiltrosCapas()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            // List the nested(anidadas) layer filters. NeestedFilters siginifca que hay filtros dentro de otros filtros.
            List&amp;lt;toolsC3D.Filtros_Capas&amp;gt; listaFiltros = new List&amp;lt;toolsC3D.Filtros_Capas&amp;gt;();   // instancia de la nueva lista
            Filtros_Capas aBobj = default(Filtros_Capas);

            LayerFilterTree lft = db.LayerFilters; //esquema en arbol de la lista de filtros.
            Autodesk.AutoCAD.LayerManager.LayerFilterCollection lfc = db.LayerFilters.Root.NestedFilters;
           
      
            for (int i = 0; i &amp;lt;= lfc.Count - 1; i++)
            {
                if (lfc[i].Name == "Nuevas capas no reconciliadas" || lfc[i].Name == "Modificaciones de ventana")
                {
                }
                else
                {
                    aBobj = new toolsC3D.Filtros_Capas();
                    aBobj.Name = lfc[i].Name;
                    listaFiltros.Add(aBobj);
                }
            }
            



            return listaFiltros;

        }


        public static List&amp;lt;BaseObject&amp;gt; Get_Capas(string NombreFiltro)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            List&amp;lt;BaseObject&amp;gt; listaCapas = new List&amp;lt;BaseObject&amp;gt;();   // instancia de la nueva lista
            BaseObject aBobj = default(BaseObject);

            Autodesk.AutoCAD.LayerManager.LayerFilterCollection lfc = db.LayerFilters.Root.NestedFilters;
            int indice = 0;
            for (int i = 0; i &amp;lt;= lfc.Count - 1; i++)
            {
                if (lfc[i].Name == NombreFiltro)
                {
                    indice = i;
                }  
            }

            LayerTableRecord ltr;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                LayerTable lt = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;

                foreach (ObjectId oid in lt)
                {
                    ltr = tr.GetObject(oid, OpenMode.ForRead) as LayerTableRecord;
               
                if(lfc[indice].Filter(ltr)==true) //la capa está incluída dentro del filtro
                {
                   aBobj = new toolsC3D.BaseObject();
                    aBobj.Id = ltr.Id;

                    listaCapas.Add(aBobj); 
                }

                }
                tr.Commit();
            }


            return listaCapas;
        
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2013 17:34:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/help-get-layerids-collection-for-layerfilter-and-layergroup/m-p/4584721#M47135</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2013-11-01T17:34:03Z</dc:date>
    </item>
  </channel>
</rss>

