Revit二次开发 - 入门篇

1.创建C# 类库项目项目名称为RevitAddin

2.添加Revit插件API

   引用 - 添加引用 -添加 RevitAPI.dll 和 RevitAPIUI.dll 文件。

3.添加 System.Windows.Forms 类库

    引用 - 添加引用 -添加System.Windows.Forms,支持弹出的对话框。

4. 测试代码

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using System.Windows.Forms;

namespace HelloWorld
{
    [TransactionAttribute(TransactionMode.Manual)]
    public class HelloWorld : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            MessageBox.Show("HelloWorld", "HelloWorld");
            return Result.Succeeded;
        }
    }
}

5.打开Revit运行插件

    附加模块 - 外部工具 - Add-In Manager(Manual Mode)。

   引入项目RevitAddin生成的RevitAddin.dll。

   运行,弹出弹框。一个简单的Revit插件就完成了。

猜你喜欢

转载自blog.csdn.net/liyazhen2011/article/details/87168089