Revit2018复现《AUTODESK REVIT二次开发基础教程》代码04

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace LearnTime
{
    //必备写法
    [Transaction(TransactionMode.Manual)]
    [Journaling(JournalingMode.NoCommandData)]
    [Regeneration(RegenerationOption.Manual)]
    public class _04_execute : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            //【1】获取当前文档
            //界面交互的doc
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            //实际内容的doc
            Document doc = commandData.Application.ActiveUIDocument.Document;


            // 从当前文档对象中取到Setting对象
            Settings documentSettings = doc.Settings;
            String prompt = "Number of all categories in current Revit document: " + documentSettings.TilePatterns + "\n";

            // 用BuiltInCategory枚举值取到一个对应的Floor Category,打印其名字
           


            List floorCategory = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)
                .WhereElementIsNotElementType().ToElements().ToList();
            prompt += "Get floor category and show the name: ";
            prompt += floorCategory.First();

            TaskDialog.Show("Revit", prompt);

            return Result.Succeeded;
        }
    }
}


 

你可能感兴趣的:(AUTODESK,c#)