Opening a custom chm file from Ribbon button in Revit

By Partha Sarkar

We can use ContextualHelp class to associate custom help. ContextualHelp allows us to start a locally installed help (chm) file, or linking to an external URL for custom help. The ContextualHelp class is used to create a type of contextual help, and then RibbonItem.SetContextualHelp() or RibbonItemData.SetContextualHelp() is used to associate it with a control. When a ContextualHelp instance is associated with a control, the text "Press F1 for more help" will appear below the tooltip when the mouse hovers over the control as shown below –

 

  Revit_Custom_HelpCHM_File

 

And here is the relevant C# .NET code snippet :

 

PushButtonData pushButtonDataHello 
  = newPushButtonData(
    "PushButtonHello", 
    "Hello World", 
    _introLabPath,
    _introLabName + ".HelloWorld" ); 
 
PushButton pushButtonHello = panel.AddItem(pushButtonDataHello) asPushButton;
pushButtonHello.LargeImage = NewBitmapImage("ImgHelloWorld.png");     
pushButtonHello.ToolTip = "simple push button";
 
// ContextualHelp class is used to create a type of contextual help      
 
ContextualHelp contextHelp = new ContextualHelp(ContextualHelpType.ChmFile, @"C:TempToolTipDemo.chm");
pushButtonHello.SetContextualHelp(contextHelp);

 

Hope this is useful to you!


Comments

4 responses to “Opening a custom chm file from Ribbon button in Revit”

  1. Rajasingh Avatar
    Rajasingh

    My help file is pdf. how can i launch pdf in contextual menu

  2. Rajasingh, just set the path to your pdf file in the ContextualHelp constructor instead of chm. In fact, you can set any file type. this file will be opened in the default application, associated with this type of file.
    Regards,
    Victor.

  3. Hi there,
    is there any way to go directly to a topic within a chm file?
    James

  4. James here.
    I found this finally that shows an example:
    http://adndevblog.typepad.com/files/cp3272_snapshot_of_the_autodesk_revit_user_interface_ui_api_v1.pdf
    I am using a similar format but it doesn’t work:
    help.HelpTopicUrl = @”html/” + chmTopicName + “.htm”;

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading