Getting all document categories even subcategories

Getting all document categories even subcategories

anmh2
Contributor Contributor
1,460 Views
1 Reply
Message 1 of 2

Getting all document categories even subcategories

anmh2
Contributor
Contributor

hello, i am trying to build windows form includes all available categories in the document, but the problem is I can't get the subcategories, I tried https://thebuildingcoder.typepad.com/blog/2010/05/categories.html , but it doesn't work, can you please tell me whats wrong in my code. Many thanks.

 

 private void LoadCategories()
        {

            TreeViewCategories.Nodes.Clear();

            
      
            foreach (Category cat in m_doc.Settings.Categories)
            {
                if (cat.AllowsBoundParameters == true)
                {
                    if (!(string.IsNullOrEmpty(TxbFilterCat.Text)))
                    {
                        if (!cat.Name.ToLower().Contains(TxbFilterCat.Text.ToLower()))
                        {
                            continue;
                        }
                    }
                    TreeNode tn = TreeViewCategories.Nodes.Add(cat.Name, cat.Name);
                    tn.Tag = cat;
                }                
            }
            TreeViewCategories.Sort();
        }

 

0 Likes
1,461 Views
1 Reply
Reply (1)
Message 2 of 2

TripleM-Dev.net
Advisor
Advisor

Hi,

 

Study the API documentation, see the Category class and it's properties, alternative use Revit Lookup addin to visually inspect elements and properties in Revit.

Categories have a SubCategory property to list all (if any) sub categories, iterate those to get all categories.

SubCategories 

0 Likes