1.revit简单获取元素类型

namespace revit_text

{

    [TransactionAttribute(TransactionMode.Manual)]

    [RegenerationAttribute(RegenerationOption.Manual)]

    public class Class1 : IExternalCommand

    {

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

        {

            //UIDocument 表示用户在revit 中打开的项目对象

            //Document 表示根的revit项目对象

            UIDocument uiDoc = commandData.Application.ActiveUIDocument;

            Document revitDoc = uiDoc.Document;

            //获取选中的元素列表

            var elemList = uiDoc.Selection.GetElementIds().ToList();

            Element selElem = uiDoc.Document.GetElement(elemList[0]);//取第一个元素

            //根据元素类型id  获取元素,并把它转换成元素类型

            ElementType type = revitDoc.GetElement(selElem.GetTypeId()) as ElementType;

            string str = "元素族名称:" + type.FamilyName + "\n" + "元素类型:" + type.Name;

            TaskDialog.Show("元素参数",str);

            return Result.Succeeded;

        }

    }

 

猜你喜欢

转载自blog.csdn.net/qq_25909453/article/details/81517436