Custom Ribbon of Navisworks part 3

By Xiaodong Liang

(Continued with Custom Ribbon of Navisworks part 2)

Locations of xaml and Name File

This plug-in dll should be put under the folder

<Navisworks 2012 Installation Path>\Plugins\ADNRibbonDemo. In addition, the xaml and name file must reside in the sub-folder of the plug-in dll. The sub-folder name needs to be a Language Code such as: en-US >> English version, zh-CN >> Chinese (PRC) version.

By default, Navisworks will try to load the xaml and *.name files from the subfolder that corresponds to the current language version. For example, if you are using the Chinese version and there are two sub-folders called en-US and zh-CN. If zh-CN is available and the files do not cause any errors, Navisworks loads the dll with the zh-CN files. Otherwise, Navisworks will check if en-US is available and the files do not cause any problem. If none of files of either version are available or problematic, Navisworks will not load the plug-in dll.

image

image

 

Priority of Strings

For display names or tooltips, Navisworks check the xaml file first. If it does not specify the strings, it checks the sub-folder for localization and gets names from *.name. If both are not available, it will use the names defined in plug-in class. The advantage of defining button Text in the xaml or name file is that the plug-in can be localized. In addition, the display name of Command can be overridden dynamically by CommandState.OverrideDisplayName in function CanExecuteCommand. For image, Navisworks will check the xaml first, and then the attributes specified in the plug-in class.

e.g. in our sample:

                                      Display Names of Tabs

ribbon elements xaml *.name attributes in compiling code result in ribbon
Tab 1   “Tab1 in name file” “Custom Tab 1 – non-localised” “Tab1 in name file”
Tab 2 “CustomTab2 in xaml” “Tab2 in name file” “Custom Tab 2 – non-localised” “CustomTab2 in xaml”

 

                                Display Names of Commands

ribbon elements Dynamic override attributes in compiling code xaml *.name result in ribbon
Button 1 “Disable Button3”

or

“Enable Button3”

  “Button1 in name file” “Button1 in name file” “Disable Button3”

or

“Enable Button3”

Button 2          
Button 3   “Button 3 non-localized” “button 3” “Button3 in name file” “button 3”
Button 4       “Button4 in name file” “Button4 in name file”
Button 5       “Button4 in name file” “Button4 in name file”

 

Finally you will see the custom ribbon as shown below:

 

image

                                  Before toggle Ribbon Tab 2

 

image

                                After toggle Ribbon Tab 2 

Please refer to the sample codes for more details. The sample hard codes the actions of copying the dll, xaml and name file to “C:\Program Files\Autodesk\Navisworks Manage 2012\Plugins” in post-build event. Please adjust with your own path.

  Download ADNRibbonDemo

Further reading

The SDK sample called CustomRibbon shows some more types of custom buttons.

(End)


Comments

6 responses to “Custom Ribbon of Navisworks part 3”

  1. Thanks a lot for the detailed example.
    I successfully created and addin with its custom Ribbon Tab and Button.
    If I develop more addins, how can I add more buttons to the same Tab? If each addin has a CustomRibbonCommandHandler.cs and CustomRibbon.xaml I see that it either overwrites the other tabs or more tabs with the same name are created! I couldn’t find a way to add buttons to an existing tab…
    Thanks,

  2. Afshin Avatar
    Afshin

    Hi Xiaodong,
    Thanks for the article. I have the same problem as ‘Teocomi’ and would like to find a solution to be used in App Store for multiple products.
    Is there any way to use the same Tab for different plugins?
    Thanks,
    Afshin

  3. How do I force new lines in the .name file? I want the display name to wrap.

  4. JavierGtz Avatar
    JavierGtz

    Hello,
    I developed a plug-in that is already working and has it’s own Ribbon Tab with a title of “Tool add/ins 1” but I guess it’s a default name that I can’t change. I’m using VS 2017 and Navisworks Manage 2018.
    The weird thing here is that I already have this:
    [Plugin(“Timeliner.DumpTimelinerTasks”, // Plugin name
    “ADSK”, // Developer ID or GUID
    ToolTip = “Timeliner.DumpTimelinerTasks tool tip”, // The tooltip for the item in the ribbon
    DisplayName = “X”)] // Display name for the Plugin in the Ribbon
    [Strings(“ADNRibbonDemo.name”)]
    [RibbonLayout(“ADNRibbonDemo.xaml”)]
    [RibbonTab(“ID_CustomTab_1”, DisplayName = “X”, LoadForCanExecute = true )]
    [Command(“ID_Button_1”, Icon = “uno.ico”, LargeIcon = “uno.ico”, ToolTip = “Show a message”)]
    And Ribbon Tab “X” does not even apear at Navisworks UI! But if I change the Display Name at the Plugin declaration, the display of the button changes. I already connected the Roamer.exe and placed the correct path. And I don’t know what else to do in order to continue.
    My ultimate goal is to change the “Tool add/ins 1” and the icon of the Plugin.
    Any ideas?
    Regards in advance

  5. I had the same issue, the solution from the following page worked for me:
    https://forums.autodesk.com/t5/navisworks-api/use-same-tab-with-different-plugins/td-p/5760643

  6. Burkhard Avatar
    Burkhard

    I have the same problem as @_davewolfe.
    Neither metacharacters like \n or nor “real” linefeeds do work.
    Does anyone have a solution to this?
    Is there any reference documentation for ALL features of the custom ribbon handling?
    Thanks

Leave a Reply to BurkhardCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading