.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autodesk.AutoCAD.Ribbon

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
GeeHaa
5490 Views, 10 Replies

Autodesk.AutoCAD.Ribbon

Hi

 

I am trying to associate F1 help to a ribbon button.

 

I found this article

 

http://adndevblog.typepad.com/autocad/2012/09/associating-f1-help-with-ribbon-button.html

 

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.

10 REPLIES 10
Message 2 of 11
StephenPreston
in reply to: GeeHaa

The Autodesk.AutoCAD.Ribbon namespace is contained within AcWindows.dll.

 

Cheers,

Stephen Preston
Autodesk Developer Network
Message 3 of 11
GeeHaa
in reply to: GeeHaa

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.RibbonPaletteSet.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.DocumentManager.MdiActiveDocument.SendStringToExecute(ribBtn.CommandParameter.ToString, True, False, True)
        End If
    End Sub

End Class

 

Message 4 of 11
Balaji_Ram
in reply to: GeeHaa

Hi,

 

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.DocumentManager.MdiActiveDocument.SendStringToExecute(ribBtn.CommandParameter.ToString, True, False, True)
        End If
    End Sub

End Class

 

Regards,



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 11
GeeHaa
in reply to: GeeHaa

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?

 

Thanks Again.

Message 6 of 11
Balaji_Ram
in reply to: GeeHaa

Hi,

 

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.

 

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 11
GeeHaa
in reply to: Balaji_Ram

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.

 

Thanks Again

Message 8 of 11
Balaji_Ram
in reply to: GeeHaa

Hi,

 

I would suggest using the AutoLoader to deploy your application. The PackageContents.xml can be modified to associate F1 help topics.

http://adndevblog.typepad.com/autocad/2012/04/autoloaderf1-help-integration.html

 

 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 :

 

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a91938...

 

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.

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 11
GeeHaa
in reply to: GeeHaa

Thanks this is exactly what I needed Thank You!

Message 10 of 11
WolframKuss12
in reply to: Balaji_Ram


@Balaji_Ram wrote:

 

 

Unfortunately the HelpTopic does not get recognised

 

 


Any news on this?

Message 11 of 11
khunstad
in reply to: GeeHaa

Maybe a little late, but here is a solution (rather dirty, though) to having F1 on ribbon button tooltips open a URL: https://forums.autodesk.com/t5/net/getting-ribbon-help-to-call-html/m-p/4943910#M40083 .

 

But from AutoCAD 2015, I understand this is not necessary.

 

Best regards,

 

Knut

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost