We have demonstrated how to generate Revit ribbon creation code automatically in either C# or VB.NET with the assistance of the Ribbon Creator of Revit Addin Wizard (RevitAddinWizard) many times before. The Revit Ribbon Creator provides a cool user interface to help collect necessary data for all available ribbon groups and items, assign images big or small to them, and set up associations between Revit ribbon buttons and external commands.
The Ribbon Creator has been enhanced dramatically to facilitate the Revit .NET API ribbon creation work much better. The most noted new features are the Revit Ribbon Definition schema invention and the ribbon creator row/item edition.
Not only that, but also this. The Ribbon Creator has supported VB.NET. If the current project is a VB.NET addin for Revit and the ribbon definition is designed as the following Ribbon Creator window shows or is just loaded from the sample Revit Ribbon Definition (.RRD) file that was shown previously:
The following code will be automatically generated into the external application as selected:
Public Sub AddRibbonItemsToRibbonPanel(panel As RibbonPanel)
Dim assemFullName As String = Assembly.GetExecutingAssembly().Location
Dim assemPath As String = Path.GetDirectoryName(assemFullName)
Dim cnt1Panel_grp1Data As PulldownButtonData = New PulldownButtonData("cnt1Panel_grp1", "Pulldown")
Dim cnt1Panel_grp1 As PulldownButton = CType(panel.AddItem(cnt1Panel_grp1Data), PulldownButton)
cnt1Panel_grp1.ToolTip = ""
cnt1Panel_grp1.LargeImage = BmpImageSource("RevitAddinVB2.ExtCmd.bmp")
Dim cnt1Panel_grp1_item1Data As PushButtonData = New PushButtonData("cnt1Panel_grp1_item1", "Pulldown Member", assemFullName, "")
Dim cnt1Panel_grp1_item1 As PushButton = CType(cnt1Panel_grp1.AddPushButton(cnt1Panel_grp1_item1Data), PushButton)
cnt1Panel_grp1_item1.ToolTip = ""
cnt1Panel_grp1_item1.LargeImage = BmpImageSource("RevitAddinVB2.ExtCmd.bmp")
panel.AddSeparator()
Dim cnt2Panel_grp1_item2Data As PushButtonData = New PushButtonData("cnt2Panel_grp1_item2", "PushButton 3", assemFullName, "")
Dim cnt2Panel_grp1_item2 As PushButton = CType(panel.AddItem(cnt2Panel_grp1_item2Data), PushButton)
cnt2Panel_grp1_item2.ToolTip = ""
cnt2Panel_grp1_item2.LargeImage = BmpImageSource("RevitAddinVB2.BigC.bmp")
Dim cnt3Panel_grp1Data As SplitButtonData = New SplitButtonData("cnt3Panel_grp1", Guid.NewGuid().ToString() )
Dim cnt3Panel_grp1 As SplitButton = CType(panel.AddItem(cnt3Panel_grp1Data), SplitButton)
Dim cnt3Panel_grp1_item1Data As PushButtonData = New PushButtonData("cnt3Panel_grp1_item1", "Split Member", assemFullName, "")
Dim cnt3Panel_grp1_item1 As PushButton = CType(cnt3Panel_grp1.AddPushButton(cnt3Panel_grp1_item1Data), PushButton)
cnt3Panel_grp1_item1.ToolTip = ""
cnt3Panel_grp1_item1.LargeImage = BmpImageSource("RevitAddinVB2.smallc.bmp")
End Sub
Public Shared Function BmpImageSource(embeddedPath As String) As System.Windows.Media.ImageSource
Dim stream As Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedPath)
Dim decoder = New System.Windows.Media.Imaging.BmpBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Return decoder.Frames(0)
End Function
It is a great news for VB.NET programmers that the Ribbon Creator of RevitAddinWizard supports VB.NET now.
Recent Comments