欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Revit二次开发-1

程序员文章站 2022-04-02 10:41:33
...

引用RevitAPI.dllRevitAPIUI.dll
1、Revit外部命令

namespace HelloRevit
{
    /*添加外部命令*/
    [Autodesk.Revit.Attributes.Transaction(
        Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class Class1:IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(
                        ExternalCommandData revit, 
                        ref string message, ElementSet elements)

        {
            TaskDialog.Show("Revit", "Hello World");
            return Autodesk.Revit.UI.Result.Succeeded;
        }
    }
}

2、添加选项卡

public class CsAdd:Autodesk.Revit.UI.IExternalApplication
    {
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
        {
            RibbonPanel ribPanel = application.CreateRibbonPanel("NewRibbonPanel");
            PushButton pBtn = ribPanel.AddItem(new PushButtonData("HelloRevit",
                "HelloRevitPan", @"[路径]\HelloRevit.dll",
                "HelloRevit.Class1")) as PushButton;
            Uri uriImg = new Uri(@"[路径]\logo.ico");
            BitmapImage largeImage = new BitmapImage(uriImg);
            pBtn.LargeImage = largeImage;
            return Result.Succeeded;
        }
        public Result OnShutdown(UIControlledApplication application)
        {
            return Result.Succeeded;
        }
    }
相关标签: Revit