BuiltInCategory

BuiltInCategory

stephen_harrison
Advocate Advocate
2,098 Views
1 Reply
Message 1 of 2

BuiltInCategory

stephen_harrison
Advocate
Advocate

I am constructing a treeview to match that within the Parameter Properties dialog that displays Categories for binding by Instance or Type. The only way I have found to achieve this is by creating two lists from the Built in Categories and iterating through them to retrieve their names.

This has worked fine with one exception.

Within the stairs category there are 3 sub categories (Landings, Runs and Supports) the respective BuiltInCategories I believe are:

BuiltInCategory.OST_StairsLandings,

BuiltInCategory.OST_StairsRuns,

BuiltInCategory.OST_StairsSupports,

 

When retrieving the name for BuiltInCategory.OST_StairsSupports the programme crashes.

The code for retrieving the name and adding to a list is:

 

foreach (BuiltInCategory builtInCategory in ParamGroups.parameterType())
            {
                Category c = doc.Settings.Categories.get_Item(builtInCategory);
 
                if (c != null)
                {
                    //make list of category names
                    typeCategories.Add(c.Name);
                }
            }

 

The fact that the code works fine for all the categories but OST_StairsSupports suggests the code is OK?

Therefore is this the correct BuiltInCategory and is there a better way to create this treeview to match the Parameter Properties dialog?

Finally is there a way to filter the categories by discipline like the Parameter Properties dialog ?

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

augusto.goncalves
Alumni
Alumni
Indeed some BuiltInCategories are expected to not have a corresponding Category, see a complete discussion at http://thebuildingcoder.typepad.com/blog/2012/09/categories-collection-item-accessor-fails.html
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes