Hide Category in View

# START TRANSACTION
t = Transaction(doc, __title__)
t.Start()

# GET ANNOTATION CATEGORIES
all_categories  = doc.Settings.Categories
cats_annotation = [cat for cat in all_categories if cat.CategoryType == CategoryType.Annotation]

# HIDE ANNOTATION CATEGORIES EXCEPT SECTIONBOX
exclude = [BuiltInCategory.OST_SectionBox]
for cat in cats_annotation:
    if cat.BuiltInCategory in exclude:
        continue
    view.SetCategoryHidden(cat.Id, True)

t.Commit()

⌨️ Happy Coding!
Erik Frits