(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.
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:
Before toggle Ribbon Tab 2
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.
Further reading
The SDK sample called CustomRibbon shows some more types of custom buttons.
(End)