Ok im totally lost here with this. Figured this after at least getting over the hurdle of trying to set up the project and all would be much easier to use and deploy (maybe even faster in AutoCAD) than what im trying to do right now using CUI files which can take 30-45 seconds to load each ribbon bar.
Trying to create extra ribbon tabs and pannels each with multiple items in drop down windows and such. Basically im trying to get rid of the tool pallet function and replace it with this item. So far I've done this just using the CUI editor in autocad but its time consuming (not easy to switch between macro's) and takes long to load on the first launch of it.
I really don't know much about VB or .net or anything. Though I have been learning more recently, with a little bit in excel trying to make customized documents for my department. I have AutoCAD 2010, and have Visual Studio 2010 Professional. Any help would be apperciated, expecially if there is some templates that I could load easily, currently not having any luck with the files from the website ObjectARX 2010 or a AutoCAD2010VBNetTemplateSetup.zip I got from another site.
Solved! Go to Solution.
Well at least I got a template up and runnig at least to debug mode now.
Another question I have is that is it possible to have a .dll (weather the one the main project one or a seperate file) load images into them?
Looking at loading some 2500 images maybe more. Got about 500 to add right away and others to add over time.
Thats a small sample of what im doing. Under each pull down there can be another 5-20 options. Probably 10-12 tabs, each with 20 or so panels. Any help pointing me into the right direction would be great!
All that was done in the autocad CUI, though its buggy and if it can be transfered between AutoCAD revs easier later on it would be great, and probably easier to edit for future updates.
Hi there please look at te following post:
I'll think it will help you getting started.
Kind regards,
Irvin
Alright im getting somewhere now.
Attached is my project file as is. Finally was able to find a tutorial done from AU back in 2009
http://images.dcheetahimages.com/au.autodesk.com/ama/images/media/AU09_SpeakerHandout_CP208-2.pdf
So started going through it finally got a tab to be created, though now running in issues trying to get the panel to load with buttons. I've copied it exactly though not sure what im doing wrong with this.
Below is the code so far (as can be seen also attached)
Though my one spot im having issues with is the AdskCommandHandler Class. Specifically
SendStringToExecute(_
ribBtn.CommandParameter, True, False, True)
Imports System Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Windows Imports Autodesk.Windows Public Class Testing Implements IExtensionApplication Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize createRibbon() End Sub Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate End Sub Private Sub CreateRibbon() 'declare a ribboncontrol object Dim ribCntrl As RibbonControl = ComponentManager.Ribbon 'create a ribbontab Dim ribTab As New RibbonTab() 'set a few properties ribTab.Title = "AU2009" ribTab.Id = "AU2009" 'add the tab to the ribbon ribCntrl.Tabs.Add(ribTab) 'set as active tab ribTab.IsActive = True End Sub Private Sub addContent(ByVal ribTab As RibbonTab) 'create the panel source Dim ribSourcePanel As RibbonPanelSource = New RibbonPanelSource() ribSourcePanel.Title = "Dev Tools" 'now the panel Dim ribPanel As New RibbonPanel() ribPanel.Source = ribSourcePanel ribTab.Panels.Add(ribPanel) 'create a button Dim ribButton1 As RibbonButton = New RibbonButton() ribButton1.Text = "Net Load" ribButton1.CommandParameter = "NETLOAD " ribButton1.ShowText = True ribButton1.CommandHandler = New AdskCommandHandler() 'add the button ribSourcePanel.Items.Add(ribButton1) End Sub End Class Public Class AdskCommandHandler Implements System.Windows.Input.ICommand Public Function CanExecute(ByVal parameter As Object) As Boolean _ Implements System.Windows.Input.ICommand.CanExecute Return True End Function Public Event CanExecuteChanged As EventHandler Implements _ System.Windows.Input.ICommand.CanExecuteChanged Public Sub Execute(ByVal parameter As Object) Implements _ System.Windows.Input.ICommand.Execute Dim ribBtn As RibbonButton = TryCast(parameter, RibbonButton) If ribBtn IsNot Nothing Then Autodesk.AutoCAD.ApplicationServices.Application. DocumentManager.MdiActiveDocument. SendStringToExecute(_ ribBtn.CommandParameter, True, False, True) End If End Sub End Class
Any help apperciated.
Hi Deathman,
I modifyed your code and in now displays a ribbon a tab buttons and fixed your command handler and add functions to remove the ribbon and use vb.net resourceimages. In the solution explorer click the project richt click propperties choose resources and then Add Resource.
Here's the code and revised project attached.
Imports System Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports System.Windows.Media.Imaging Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Windows Imports Autodesk.Windows Public Class Testing Implements IExtensionApplication Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize createRibbon() End Sub Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate End Sub Public Sub createRibbon() Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.Windows.ComponentManager.Ribbon If ComponentManager.Ribbon Is Nothing Then Return End If For i As Integer = 0 To ribCntrl.Tabs.Count - 1 If ribCntrl.Tabs(i).Id.Equals("My_Rib_ID") Then Return End If Next 'add the tab Dim ribTab As New RibbonTab() ribTab.Title = "ACME RIBBON" ribTab.Id = "My_Rib_ID" ribCntrl.Tabs.Add(ribTab) 'create and add the panels addPanel1(ribTab) 'set as active tab ribTab.IsActive = True End Sub Private Sub removeRibbon() Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.Windows.ComponentManager.Ribbon 'find the custom tab using the Id For i As Integer = 0 To ribCntrl.Tabs.Count - 1 If ribCntrl.Tabs(i).Id.Equals("My_Rib_ID") Then ribCntrl.Tabs.Remove(ribCntrl.Tabs(i)) Return End If Next End Sub Private Sub addPanel1(ByVal ribTab As RibbonTab) 'create the panel source Dim ribSourcePanel As New RibbonPanelSource() ribSourcePanel.Title = "PanelName" 'now the panel Dim ribPanel As New RibbonPanel() ribPanel.Source = ribSourcePanel ribTab.Panels.Add(ribPanel) Dim ribbonbutton1 As New RibbonButton() ribbonbutton1.Text = "Net Load" ribbonbutton1.CommandParameter = "NETLOAD " ribbonbutton1.ShowText = True ribbonbutton1.ShowImage = True ribbonbutton1.Image = getBitmap(My.Resources.Rib_16) ribbonbutton1.LargeImage = getBitmap(My.Resources.Rib_32) ribbonbutton1.Orientation = System.Windows.Controls.Orientation.Vertical ribbonbutton1.Size = RibbonItemSize.Large ribbonbutton1.CommandHandler = New AdskCommandHandler() Dim ribbonbutton2 As New RibbonButton() ribbonbutton2.Text = "LINE" ribbonbutton2.CommandParameter = "LINE " ribbonbutton2.ShowText = True ribbonbutton2.ShowImage = True ribbonbutton2.CommandHandler = New AdskCommandHandler() Dim ribbonbutton3 As New RibbonButton() ribbonbutton3.Text = "Polyline" ribbonbutton3.CommandParameter = "PLINE" ribbonbutton3.ShowText = True ribbonbutton3.ShowImage = True ribbonbutton3.CommandHandler = New AdskCommandHandler() Dim ribbonbutton4 As New RibbonButton() ribbonbutton4.Text = "Circle" ribbonbutton4.ShowText = False ribbonbutton4.CommandParameter = "CIRCLE " ribbonbutton4.ShowImage = True ribbonbutton4.CommandHandler = New AdskCommandHandler() Dim ribbonbutton5 As New RibbonButton() ribbonbutton5.Text = "DialogLauncher" ribbonbutton5.CommandParameter = "properties " ribbonbutton5.ShowText = True ribbonbutton5.ShowImage = True ribbonbutton5.CommandHandler = New AdskCommandHandler() Dim rowpanel As New RibbonRowPanel() rowpanel.Items.Add(ribbonbutton2) rowpanel.Items.Add(New RibbonRowBreak()) rowpanel.Items.Add(ribbonbutton3) rowpanel.Items.Add(New RibbonRowBreak()) rowpanel.Items.Add(ribbonbutton4) 'and add it to source ribSourcePanel.DialogLauncher = ribbonbutton5 ribSourcePanel.Items.Add(ribbonbutton1) ribSourcePanel.Items.Add(New RibbonSeparator()) ribSourcePanel.Items.Add(rowpanel) End Sub Public Function getBitmap(ByVal image As Bitmap) As BitmapImage Dim stream As New MemoryStream() image.Save(stream, ImageFormat.Png) Dim bmp As New BitmapImage() bmp.BeginInit() bmp.StreamSource = stream bmp.EndInit() Return bmp End Function End Class Public Class AdskCommandHandler Implements System.Windows.Input.ICommand Public Function CanExecute(ByVal parameter As Object) As Boolean _ Implements System.Windows.Input.ICommand.CanExecute Return True End Function Public Event CanExecuteChanged As EventHandler Implements _ System.Windows.Input.ICommand.CanExecuteChanged Public Sub Execute(ByVal parameter As Object) Implements _ System.Windows.Input.ICommand.Execute Dim ribBtn As RibbonButton = TryCast(parameter, RibbonButton) If ribBtn IsNot Nothing Then Autodesk.AutoCAD.ApplicationServices.Application. DocumentManager.MdiActiveDocument. SendStringToExecute( ribBtn.CommandParameter, True, False, True) End If End Sub End Class
Kind regards,
Irvin
Hi
Thanks to this thread I have got some code running in AutoCAD 2011.
Out of interest where is the RibbonButton.CommandParameter documentation? It took me a while to realise I needed a sapce at the end of the command string.
Regards
The RibbonButton.CommandParameter really doesn't have much documentation that I know of. Really its a thirdparty command added in to Mock the command line.
As for the space, and the reason for it after the command, it acts like an enter key. Just like if you type in "pl" and hit space or enter after it, it will start the polyline command in autocad.
Can't find what you're looking for? Ask the community or share your knowledge.