After going through the previous chapters, we are able to create an independent MDL program. But it is inconvenient to execute the program by typing commands every time. This chapter will introduce how to create a Ribbon interface so that users can launch our program with a mouse click. The interface of MSCE completely uses Ribbon technology, and the interface of MSV8i has changed a lot. Refer to the figure below to understand what Workflow, Tab, Group, and Button are. We will use these basic concepts in our step-by-step exercises.
MicroStation software provides powerful customization capabilities that allow you to associate applications with MicroStation interfaces without writing a single line of code. These customizations need to be saved in a type of file called a design file library (file extension.DGNLIB), and these DGNLIB files are automatically loaded when MicroStation starts.
The various resources used in MicroStation (such as text styles, callout styles, print styles, display styles, detail symbol styles, etc.) are best stored in different DGNLIB files in different categories, and their locations are subject to configuration variables. Select the menu File > Settings > Configuration > Configuration Variables to open the configuration variables dialog box, and then enter DGNLIBLIST in the search field to filter out all configuration variable names that contain DGNLIBLIST.
For example, MS_DGNLIBLIST_TEXTSTYLES is used to control which folders MicroStation scans for DGNLIB files containing text styles when starting, and MS_DGNLIBLIST_DIMENSIONSTYLES is used to control which folders MicroStation scans for DGNLIB files with label styles when it starts. What we want to focus on is the variable MS_GUIDGNLIBLIST, which controls which folders MicroStation scans for the interface modified DGNLIB files when it starts.
Q1. Why introduce the concept of configuration variables?
Ans: Configuration variables are similar to Windows environment variables. They are designed to make programs more versatile. For example, different users may install MicroStation in different paths, and currently, we may choose different Workspace and Workset, then how does our code know the specifics of the default DGN file? This can be obtained by accessing the configuration variable MS_DEF. The default value of this variable is C:\ProgramData\Bentley\MicroStation CONNECT Edition\Configuration\WorkSpaces\Example\WorkSets\MetroStation\Dgn\ .In addition, configuration variables can control some behavior of the MicroStation software. For example, MS_WORKMODE can determine whether the software works in DGN or DWG mode.
Q2. Why does MS_GUIDGNLIBLIST contain multiple paths?
Ans: MicroStation processes many configuration files at startup. The extension of the configuration file can be CFG, PCF, or UCF, and each configuration file contains one or more configuration variables (the detailed configuration file syntax can be found in the software help file). The final value of each configuration variable you see is accumulated after processing multiple configuration variables. Each level (a total of seven levels of configuration: system level, application level, organization level, site level, project level, role level, user level) configuration file can attach the value of this level to the same configuration variable. In the end, a variable will have multiple values. Specific to the variable MS_GUIDGNLIBLIST, if we put the DGNLIB file under \Bentley\ MicroStation CONNECT Edition \ Configuration \Organization\dgnlib\GUI, it means that no matter which workspace you choose, you can see your customized content.
If you put the DGNLIB file under Bentley\MicroStation CONNECT Edition\Configuration\WorkSpaces\Example\Standards\DgnLib\GUI, you can only select the Example workspace (regardless of the workset) to see it. If you put the DGNLIB file under Bentley\ MicroStation CONNECT Edition\Configuration\WorkSpaces\
Example\WorkSets\MetroStation\Standards\Dgnlib\GUI, you must select the MicroStation working set under the Example workspace to see you Customized content. Providing this flexibility allows us to customize common things to a higher level and unique things to a lower level. If you are not clear about the concepts introduced here, please take the MicroStation Administrator related tutorial.
Next, we will guide you step by step to customize your own interface
a. Start MSCE, select the menu File > New, browse to the folder C:\ProgramData\Bentley\MicroStation CONNECT Edition\Configuration\Organization\dgnlib\GUI, then type HelloWorld.dgnlib, click the Save button to create the DGNLIB file. As shown below:
b. Exit MSCE and restart. Open our dgnlib again. The DGNLIB is loaded only when the MS starts, the purpose of restarting the MS is to let the MS load the newly created HelloWorld.dgnlib. If you later want to customize the interface in the DGNLIB file, this step is not needed.
c. Right-click in the Ribbon interface area and select Customize Ribbon from the pop-up menu to open the custom Ribbon interface dialog box. Please note that at this time, the title of your custom Ribbon interface dialog box must display dgnlib instead of Personal.dgnlib.
If the title bar shows Personal.dgnlib, your settings are incorrect. The possible reasons are:
d. If we want to put our tool under the Content page of an existing Drawing workflow, expand the Drawing workflow, and find Content. Right-click Content and select Add New Group from the pop-up menu to create a new group. Enter the group name HelloWorld, then right-click the HelloWorld group and select Add New Button from the pop-up menu to create a new button. Enter the button name "Place Surface".
e. Enter MDL LOAD HelloWorld;HelloWorld Create BsplineSurface in the Key-in field in the lower property area to load our application and issue a command to place the surface. Set Size to Large. Click the Apply button in the lower right corner to apply all settings. Switch to the Content page to see our customized effect.
f. From the Ribbon interface, you can see that our tool icon is still a default wrench icon. To use our own icon, click Custom Tools and Tasks in the bottom left corner of the custom Ribbon interface dialog box to open the custom dialog box. Switch to the Icons page in the customization dialog box, click the plus drop-down button, select From Ico Files in the pop-up menu, and find an ICO icon file you have prepared in the pop-up interface.
g. Switch to the custom Ribbon interface, find our "Place Surface" tool, click the browse button behind its Icon property bar, and look for Look in icons in the Define Icon for the Tool dialog box that pops up (Search icon location) Select Current Design File to see the icon name we imported in the previous step. Select it and click the Apply button in the bottom right corner of the Customize Ribbon dialog box again to apply the settings. The customized interface is shown in the following figure.
h. Open any DGN file in MSCE and switch to the 3D model. Select the "Place Surface" tool under Content in the Ribbon interface to launch the tool we saw in the previous picture.
i. If you want to distribute your customized content to other users, you can directly copy the DGNLIB to other users C:\Program Data\ Bentley\ MicroStation CONNECT Edition\ Configuration\Organization\dgnlib\GUI folder. Of course, the required ma and HelloWorld.dll should also be copied to the C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation \ Mdlapps folder of other users.
j. Of course, these copying actions are best implemented in an installer. Because different users may install MSCE in different locations, the installer needs to query the Windows registry to find the ConfigurationPath and ProgramPath under HKEY_LOCAL_MACHINE\SOFTWARE\Bentley\MicroStation\ {XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX} to get an error-free installation. As shown below:
Prev:[[Adding User Interface to a MDL Application]] | Creating elements in MDL applications |