I am trying to associate F1 help to a ribbon button.
I found this article
I am using VB2010 express with AutoCAD 2013. Along with the usual acmgd.dll, acdbmgd.dll, accoremgd.dll, I am referencing AcCui.dll and AdWindows.dll
What I need to know is what reference I need to be able to see Autodesk.AutoCAD.Ribbon in intellisense.
Thanks In advance.
Solved! Go to Solution.
Thanks very Much that did the trick. I tried to translate the C# into Vb.net But I'm getting the following error.
Unable to cast object of type 'F1_Help.AdskCommandHandler' to type 'System.Windows.Input.ICommand'.
Any Help would be much appreciated.
<CommandMethod("CRB")> _ Public Sub CRB() Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPalet
teSet.RibbonControl Dim ribTab As RibbonTab = New RibbonTab ribTab.Title = "F1 Help Test" ribTab.Id = "My_Tab_ID" ribCntrl.Tabs.Add(ribTab) Dim ribSourcePanel As Autodesk.Windows.RibbonPanelSource = New RibbonPanelSource ribSourcePanel.Title = "Controls" Dim ribPanel As RibbonPanel = New RibbonPanel ribPanel.Source = ribSourcePanel ribTab.Panels.Add(ribPanel) Dim ribToolTip As RibbonToolTip = New RibbonToolTip ribToolTip.Command = "My Command" ribToolTip.Title = "My Title" ribToolTip.Content = "My Content" ribToolTip.ExpandedContent = "my Expanded Content !" 'enable f1 Help ribToolTip.IsHelpEnabled = True Dim ribRow1 As RibbonRowPanel = New RibbonRowPanel ribRow1.Tag = "Row1" Dim ribButton As RibbonButton = New RibbonButton ribButton.Text = "PLINE" ribButton.ShowText = True ribButton.CommandParameter = "\Xlb\Xlb_PLINE" ribButton.CommandHandler = New AdskCommandHandler ribButton.HelpSource = New System.Uri("C:\Contents\Sample.chm", UriKind.RelativeOrAbsolute) ribButton.HelpTopic = "Sanmple" ribButton.IsToolTipEnabled = True ribButton.ToolTip = ribToolTip ribSourcePanel.Items.Add(ribButton) ribTab.IsActive = True End Sub End Class Public Class AdskCommandHandler 'Implements System.Windows.Input.ICommand Public Function CanExecute(ByVal parameter As Object) As Boolean Return True End Function Public Event CanExecuteChanged As EventHandler Public Sub Execute(ByVal parameter As Object) Dim ribBtn As Autodesk.Windows.RibbonButton = TryCast(parameter, Autodesk.Windows.RibbonButton) If ribBtn.CommandParameter.ToString <> "" Then Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument.SendStringToExecu te(ribBtn.CommandParameter.ToString, True, False, True) End If End Sub End Class
Can you please try this VB.Net code for the command handler 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( _ ByVal sender As Object, ByVal e As System.EventArgs) _ Implements System.Windows.Input.ICommand.CanExecuteChanged Public Sub Execute(ByVal parameter As Object) _ Implements System.Windows.Input.ICommand.Execute Dim ribBtn As Autodesk.Windows.RibbonButton = TryCast(parameter, Autodesk.Windows.RibbonButton) If ribBtn.CommandParameter.ToString <> "" Then Autodesk.AutoCAD.ApplicationServices.Application.D
ocumentManager.MdiActiveDocument.SendStringToExecu te(ribBtn.CommandParameter.ToString, True, False, True) End If End Sub End Class
Thanks that worked. It creates a new ribbon tab etc. and the chm file comes up when I hit F1 help. But I can't find the tab or panel in the CUI. and if I close AutoCAD and reopen It is gone. Do I need to somehow attach it to a workspace?
There are two different sets of API to work with ribbons in AutoCAD. The runtime ribbon API and the CUI API. The sample code that is being used here is the ribbon runtime API and the ribbon tabs created using it are not saved in the CUIx file.
When using the runtime ribbon API, it is needed to setup your command for load at AutoCAD startup. This is to ensure that those ribbon tabs get created everytime AutoCAD starts.
Is there a way to associate F1 help to a button using the CUI API? I've been looking through the properties and I don't see anything like helpsource.
If I could do it without a program that would be fine too. At the end of the day what I need is to have a CUIx file where F1 Help for buttons is associated with a CHM file.
I would suggest using the AutoLoader to deploy your application. The PackageContents.xml can be modified to associate F1 help topics.
But if you need to do this from the CUI dialog, then it can be done by associating an extended help xaml file for your command.
You can find a sample extended help xaml file here :
To associate F1 help, you will need the line in the above post to be modified as
<src:RibbonToolTip x:Key="MYEH_CMD_0002" HelpSource = "ToolTipDemo.chm" HelpTopic = "CreateLayer">
Unfortunately the HelpTopic does not get recognised although the chm opens on pressing F1.
For this we have a request logged with our engineering team.