下載app免費(fèi)領(lǐng)取會(huì)員
網(wǎng)友投稿
更多在Revit API 論壇里看到了一個(gè)人在問(wèn),怎樣實(shí)現(xiàn)在modeless對(duì)話框中
禁止刪除操作,大概想了一下,可以通過(guò)下面3個(gè)步驟實(shí)現(xiàn)
1.在對(duì)話框顯示的時(shí)候,復(fù)寫刪除命令
2.寫一個(gè)外部命令來(lái)刪除1中復(fù)寫的命令
3.在對(duì)話框關(guān)閉后調(diào)用這個(gè)外部事件
下面是關(guān)鍵代碼:
UIApplication uiapp = commandData.Application;
Window1 myWin = new Window1(uiapp);
myWin.Show();
return Result.Succeeded;
public partial class Window1 : Window
{
UIApplication uiapp = null;
ExEvent myEvent =null;
ExternalEvent myEventHandler = null;
public Window1()
{
InitializeComponent();
}
public Window1(UIApplication uiapp)
{
InitializeComponent();
AddInCommandBinding binding = uiapp.CreateAddInCommandBinding(RevitCommandId.LookupPostableCommandId(PostableCommand.Delete));
binding.Executed += Execute;
this.uiapp = uiapp;
myEvent = new ExEvent();
myEventHandler = ExternalEvent.Create(myEvent);
}
private void Execute(object sender, Autodesk.Revit.UI.Events.ExecutedEventArgs e)
{
MessageBox.Show("窗體關(guān)閉之前無(wú)法做刪除操作!");
}
private void Window_Closed(object sender, EventArgs e)
{
myEventHandler.Raise();
}
}
public class ExEvent : IExternalEventHandler
{
public void Execute(UIApplication app)
{
app.RemoveAddInCommandBinding(RevitCommandId.LookupPostableCommandId(PostableCommand.Delete));
}
public string GetName()
{
return "test";
}
}
本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。
上一篇:二次開(kāi)發(fā)教程:Revit開(kāi)發(fā)通過(guò)Category設(shè)置構(gòu)件顏色
下一篇:二次開(kāi)發(fā)教程:Revit開(kāi)發(fā)之調(diào)用過(guò)濾器設(shè)置窗體設(shè)置過(guò)濾器
推薦專題