is there any analog of LabelUtils.GetLabel(BuiltIncategory) earlier than 2020?

is there any analog of LabelUtils.GetLabel(BuiltIncategory) earlier than 2020?

Extraneous
Advisor Advisor
571 Views
2 Replies
Message 1 of 3

is there any analog of LabelUtils.GetLabel(BuiltIncategory) earlier than 2020?

Extraneous
Advisor
Advisor

Hi everyone,

Is there any analog of the method LabelUtils.GetLabel for BuiltInCategory? It has been introduced only in Revit 2020, but I need to show the translated list of categories in 2019 and earlier. Thank you in advance!

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Accepted solutions (1)
572 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

I should think that for all the categories available in the document, you can say:

   

    void BuiltInCategoryNames( Document doc )
    {
      Categories categories = doc.Settings.Categories;

      Array bics = Enum.GetValues(
        typeof( BuiltInCategory ) );

      foreach( BuiltInCategory bic in bics )
      {
        try
        {
          Category cat = categories.get_Item( bic );

          Debug.Print( cat.Name );
        }
        catch( Exception )
        {
        }
      }
    }

 

Check out The Building Coder samples CmdCategories, especially at the end:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3

Extraneous
Advisor
Advisor

Yes, it was easy, Category.Name shows a translated name of category. It could be guessed by myself 🙂

Thank you Jeremy!

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram