Active Member
Posts: 6
Registered: ‎09-11-2013
Message 1 of 2 (549 Views)

How to Customize top level UI to Ribbons using VB.NET for AUTOCAD 2014

549 Views, 1 Replies
09-11-2013 11:26 AM

Hi, I want to create plug-in that customize most top useful UI, menu command or options to the Ribbon for the Autocad 2014 using vb.net 2010/12

Valued Contributor
Posts: 91
Registered: ‎12-05-2011
Message 2 of 2 (534 Views)

Re: How to Customize top level UI to Ribbons using VB.NET for AUTOCAD 2014

09-11-2013 02:54 PM in reply to: imvivs

I will share my code provided if you gety it working you share the finished code back here.  I am having errors with starting up the app at line 29.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Customization
Imports Autodesk.Windows

Namespace RibbonClass

   Public Class RibbonMake
      Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

      Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
         ' Create an AutoCAD toolbar with 4 buttons linked to the 4 commands defined below

         Dim LecModule As System.Reflection.Module = System.Reflection.Assembly.GetExecutingAssembly().GetModules()(0)
         Dim LecModulePath As String = LecModule.FullyQualifiedName
            LecModulePath = LecModulePath.Substring(0, LecModulePath.LastIndexOf("\"))
            MsgBox("Error with Module Path")
            Exit Sub
         End Try

         Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
		 ''--------this next statement is where I am having problems.
         AddHandler Application.Idle, AddressOf callback_Idle
      End Sub

      Private Sub callback_Idle(ByVal sender As [Object], ByVal e As EventArgs)
         RemoveHandler Application.Idle, AddressOf callback_Idle
      End Sub

      Private Sub CreateRibbon()
         Dim mainAcadRibbon As Autodesk.Windows.RibbonControl = Autodesk.Windows.ComponentManager.Ribbon '   ComponentManager.Ribbon
         If mainAcadRibbon IsNot Nothing Then
            Dim rTab As RibbonTab = mainAcadRibbon.FindTab("Tab Name")
            If rTab IsNot Nothing Then
            End If
            rTab = New RibbonTab()
            rTab.Title = "Title"
            rTab.Id = "ID"
         End If
      End Sub

      Private Shared Sub addPanelsToRibbon(ByVal rtab As RibbonTab)
      End Sub

      Private Shared Function panelExample() As RibbonPanel
         Dim rb1 As Autodesk.Windows.RibbonButton
         Dim rb2 As Autodesk.Windows.RibbonButton
         Dim rps As New Autodesk.Windows.RibbonPanelSource()
         rps.Title = "Title"
         Dim rp As New RibbonPanel()
         rp.Source = rps

         rb1 = New Autodesk.Windows.RibbonButton()
         rb1.Name = "Name1"
         rb1.ShowText = True
         rb1.Text = "Text1"
         rb1.CommandHandler = New RibbonCommandHandler()

         rb2 = New Autodesk.Windows.RibbonButton()
         rb2.Name = "Name2"
         rb2.ShowText = True
         rb2.Text = "Text2"
         rb2.CommandHandler = New RibbonCommandHandler()

         Return rp
      End Function

      Public Class RibbonCommandHandler
         'Implements System.Windows.Input.ICommand

         Public Function CanExecute(ByVal parameter As Object) As Boolean
            Return True
         End Function

         ' CanExecuteChanged must be implemented, even if not used.
         Public Event CanExecuteChanged As EventHandler

         Public Sub Execute(ByVal parameter As Object)
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            If TypeOf parameter Is Autodesk.Windows.RibbonButton Then
               Dim button As Autodesk.Windows.RibbonButton = TryCast(parameter, Autodesk.Windows.RibbonButton)
                  Select Case button.Name.ToString()
                     Case "Name1"
                        Exit Select
                     Case "Name2"
                        Exit Select
                     Case Else
                        Exit Select
                  End Select
               Catch ex As Autodesk.AutoCAD.Runtime.Exception
               Catch ex As System.NullReferenceException
               End Try
            End If
         End Sub
      End Class

      Private Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
      End Sub

   End Class

   End Namespace


Learning as I go
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.