start

[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
    public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
    {
        UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
        Document doc = uiDoc.Document;
        Selection sel = uiDoc.Selection;         Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
        try
        {
            ts.Start();
            //找到类型的方法,这里找到文字注释类型
            Categories cates = doc.Settings.Categories;
            Category cate = cates.get_Item(BuiltInCategory.OST_TextNotes);
            //设置类型可见性
            doc.ActiveView.setVisibility(cate, false);
            ts.Commit();
        }
        catch (Exception ex)
        {
            //WinFormTools.MsgBox(ex.ToString());
        }
        return Result.Succeeded;
    }
}

url:http://greatverve.cnblogs.com/p/category-setVisibility.html

05-11 19:40