学习3、Revit二次开发:简单的按钮

Revit启动后自动在附加模块Ribbon面板中添加两按钮,按钮1和按钮2

Imports Autodesk.Revit.UIImports Autodesk.Revit.DBImports Autodesk.Revit.AttributesNamespace MyFirstRevitDll4 Public Class Class1 Implements IExternalApplication Dim AddinsPath As String Public Function OnShutdown(application As UIControlledApplication) As Result Implements IExternalApplication.OnShutdown Return Result.Succeeded End Function Public Function OnStartup(application As UIControlledApplication) As Result Implements IExternalApplication.OnStartup Dim VersionNumber As String = application.ControlledApplication.VersionNumber Dim CommonApplicationData As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) 'Dim CommonApplicationData As String = Environment.ExpandEnvironmentVariables('%PROGRAMDATA%') Dim AddinsPath As String = IO.Path.Combine(CommonApplicationData, 'Autodesk\Revit\Addins\' & VersionNumber)
Dim ribbonPanel1 As RibbonPanel = application.CreateRibbonPanel('功能A')
Dim item1 As RibbonItemData = New PushButtonData('按钮1', '按钮1', AddinsPath & '\MyFirstRevitAddIn4.dll', 'MyFirstRevitAddIn41.MyFirstRevitDll4.Class2') Dim item2 As RibbonItemData = New PushButtonData('按钮2', '按钮2', AddinsPath & '\MyFirstRevitAddIn4.dll', 'MyFirstRevitAddIn41.MyFirstRevitDll4.Class3') Dim listRibbon1 As IList(Of RibbonItem) = ribbonPanel1.AddStackedItems(item1, item2)
Return Result.Succeeded End Function End Class <Transaction(TransactionMode.Manual)> Public Class Class2 Implements IExternalCommand Private Function Execute(ByVal commandData As ExternalCommandData, ByRef message As String, ByVal elements As ElementSet) _ As Result Implements IExternalCommand.Execute MsgBox('运行按钮1') Return Result.Succeeded End Function End Class <Transaction(TransactionMode.Manual)> Public Class Class3 Implements IExternalCommand Private Function Execute(ByVal commandData As ExternalCommandData, ByRef message As String, ByVal elements As ElementSet) _ As Result Implements IExternalCommand.Execute MsgBox('运行按钮2') Return Result.Succeeded End Function End ClassEnd Namespace

Addin

(0)

相关推荐