Get Categories

Anonymous

Get Categories

Anonymous
Not applicable

HI Guys im trying to get a list of category similar to visibility graphics options as shown in the image

but for some reason im get extra items. How do i filter them?

 

1.PNG

 

 foreach (Category cat in _doc.Settings.Categories)
            {
                categories.Add(cat);
            }
            foreach(Category category in categories)
            {
                if (category.CategoryType == CategoryType.Model)
                {
                    TreeNode treeNode = new TreeNode(category.Name);
                    foreach (Category sub in category.SubCategories)
                    {
                      
                        {
                            treeNode.Nodes.Add(sub.Name);
                            
                        }
                    }

                    treeView1.Nodes.Add(treeNode);
                }
            }
0 Likes
Reply
915 Views
3 Replies
Replies (3)

TripleM-Dev.net
Advisor
Advisor

Hi,

 

Good one, never noticed, I display them in a DataGrid and never compared.

 

Maybe a couple of things:

Check if it's a builtin Category (Try to convert to a BuiltinCategory Enum)

If true then compare against you're own "internal use only list names".

 

The names seem to consist of the Function Layers + Cut/Surface pattern names.

And see if those are the only ones?...

 

Function LayersFunction LayersIllegal charsIllegal chars

 

 

 

 

 

 

 

 

 

 

 

 

I'm going to include an additional column in mine, thanx for noticing.

Add Column for those!Add Column for those!

 

- Michel

Sean_Page
Collaborator
Collaborator

See here as well.

 

https://forums.autodesk.com/t5/revit-api-forum/how-to-get-category-list/td-p/4477699

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect

TripleM-Dev.net
Advisor
Advisor

Hi @Sean_Page ,

 

That solution would not retrieve all Categories as displayed in the Object styles, as asked by OP.

However, good addition, added it also to my addin for added information.

 

As you can see below only slabedges can be bound to project parameters, several other builtin can't and neither user created subcategories.

CategoriesCategories

 

- Michel