2. revitAPI基础-----类别category

在revitAPI中,Element及其子类都拥有一个category属性用于表示类别,整体调用方式为document.settings.Categories,也可以用BuiltInCategory找出指定的类别

从模型中取到想要的类别:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
namespace category
{
    [Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)]
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //throw new NotImplementedException();
            try
            {
                UIDocument uidoc = commandData.Application.ActiveUIDocument;
                Document document = uidoc.Document;
                Categories categories = document.Settings.Categories;//得到了全部的类别
                Category category = categories.get_Item(BuiltInCategory.OST_Columns);//得到了柱子类别
                TaskDialog.Show("提示","图*有"+categories.Size+"种类别");
               
               
                return Result.Succeeded;
            }
            catch (Exception)
            {
                return Result.Failed;
            }
        }
    }
}

2. revitAPI基础-----类别category

 

 同时对于element实例,category是其一个属性,因此可以通过element获取其category属性

2. revitAPI基础-----类别category

上一篇:windows下搭建网站


下一篇:【WPF学习】第十八章 多点触控输入