Revit 二次开发 交互及UIAPI之Ribbon菜单
标签:iap cti 描述 nbu rgs collect pdb btn 操作
学习地址:https://www.bilibili.com/video/BV1mf4y1S72o?p=14
Ribbon菜单
创建控件(按钮等)
Ribbon菜单实例练习
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System.Windows.Forms;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;
using System.Windows.Media.Imaging;
namespace RevitDevTV
{
///
/// Ribbon练习
///
[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
public class Ribbon : IExternalApplication
{
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
public Result OnStartup(UIControlledApplication application)
{
application.CreateRibbonTab("我的工具");
RibbonPanel panel1 = application.CreateRibbonPanel("我的工具", "欢迎页");
PushButtonData pbd = new PushButtonData("我的工具", "欢迎使用",@"C:\Users\apple\Desktop\RevitDevTV\RevitDevTV\bin\Debug\RevitDevTV.dll", "RevitDevTV.ShowHello");
PushButton pb = panel1.AddItem(pbd) as PushButton;
RibbonPanel panel2 = application.CreateRibbonPanel("我的工具","工具");
SplitButtonData splitData = new SplitButtonData("我的集合", "创建工具");
SplitButton sb = panel2.AddItem(pbd) as SplitButton;
PushButtonData spd = new PushButtonData("我的工具", "创建", @"C:\Users\apple\Desktop\RevitDevTV\RevitDevTV\bin\Debug\RevitDevTV.dll", "RevitDevTV.ShowHello");
spd.LargeImage = new BitmapImage(new Uri(@"C:\Users\apple\Desktop\1.png"));
panel2.AddItem(spd);
panel2.AddSeparator(); //添加分割线
PulldownButtonData pdbd = new PulldownButtonData("我的工具", "检查");
PushButtonData pushbtn = new PushButtonData("我的工具", "碰撞检查", @"C:\Users\apple\Desktop\RevitDevTV\RevitDevTV\bin\Debug\RevitDevTV.dll", "RevitDevTV.ShowHello");
PulldownButton btn = panel2.AddItem(pdbd) as PulldownButton;
btn.LongDescription = "检查当前物体是否碰撞"; //添加下拉按钮的完整描述
btn.AddPushButton(pushbtn); //添加命令按钮到下拉按钮
RibbonPanel panel3 = application.CreateRibbonPanel("我的工具", "文件");
ComboBoxData cbd = new ComboBoxData("选项");
Autodesk.Revit.UI.ComboBox cBox = panel3.AddItem(cbd) as Autodesk.Revit.UI.ComboBox;
if (cBox!=null)
{
cBox.ItemText = "选择操作";
cBox.ToolTip = "请选择想要进行的操作";
cBox.LongDescription = "选择一 直接关闭,选择二关闭并修改";
ComboBoxMemberData cbmd = new ComboBoxMemberData("A", "关闭");
ComboBoxMemberData cbmd2 = new ComboBoxMemberData("B", "关闭并修改");
cbmd.GroupName = "编辑操作";
cBox.AddItem(cbmd);
cBox.AddItem(cbmd2);
}
cBox.CurrentChanged += change;
cBox.DropDownClosed += closed;
return Result.Succeeded;
}
private void closed(object sender, ComboBoxDropDownClosedEventArgs e)
{
TaskDialog.Show("关闭", "已关闭");
}
private void change(object sender, ComboBoxCurrentChangedEventArgs e)
{
TaskDialog.Show("修改", "已修改");
}
}
}
Revit 二次开发 交互及UIAPI之Ribbon菜单
标签:iap cti 描述 nbu rgs collect pdb btn 操作
原文地址:https://www.cnblogs.com/chenyanbin/p/13286200.html
评论