This was a great starting platform for me, but also left a few questions.
The first of these was how exactly are Named Expressions pick up and under what variable? The reason for this is that it wasn't clear what variable set the path to the dgnlib with the Named Expressions which was an initial confusion for me as I tried to use MS_GUIDGNLIBLIST thinking that as long as the dgnlib was picked up that it would work.
The named expressions in a dgnlib will only work if the dgnlib is in the path as defined by MS_DGNLIBLIST. A very important thing to remember as you go. As such, under my dgnlib directory in my build I have an expressions directory which has by Named Expression dgnlib files in it so I can have these in a path that can then be added to my client or project cfg files as required.
So, why use Named Expressions? Well, the main thing that drove me to investigate Named Expressions was the fact that I was sick and tired of having to maintain edited versions of by guidgnlib files for different client or project builds just so I could turn on or off some functions. For instance, I have a single guidgnlib file, easier for me to maintain. I have a client that has their own text styles etc. all delivered within their won guidgnlib files, but I still want users to have access to our cells and custom tools. I also have another client who won't allow us to use our cells, but I want our users to have access to or tools. All of these variations can be handled using the same single guidgnlib files with a few custom config variables and Named Expressions. What a relief.
Lets go through a few examples.
The first one I set up was to be able to turn on or off standard tools like dimensioning, text styles etc.
To access the Named Expressions dialog you must be in your correct dgnlib file and then go to Workspace>Customize:
This will open the Customize dialog which access your custom toolboxes etc. From here go to Utilities>Named Expressions:
This open the Named Expressions dialog:
For this to work, I decided to keep my custom variables in a similar format to make them easier to find in the config dialog.
So, for my standard items to show up, the variable:
Is_Std = 1
has to be set. I have this in my main config file in the build.
To get this to work I create a new expression in the dialog. As you can see, to make it easier I name the expressions based on the variable.
Going on the article from AskInga, I set Keywords as shown.
I then set the Symbol Sets from the drop down to Config Var:
The list of available Symbol Sets can be accessed through Utilities>Report Symbols are are a good source for what you can do to set up your Named Expressions, including the one we're about to use:
Our expression is going to be:
What this mean is our standard tools, which we will set soon, will show in our application when we have set variables:
Is_STD = 1
Is_STD = 0
then out tools will be hidden. See where this is going :-)
To make sure your expression is working, hit the Test button at the bottom. If it is True, when it is reading the variable correctly and will show the tools. If it is False, it is still reading the variable, but as the Expression is False, the tools will become hidden.
So, now that we have our expression, how do we use it?
What we need to do is set the use of the Named Expression in the tools and toolboxes in our guidgnlib. To do this, go back to the customize dialog:
There are 2 places we need to make sure the expressions are set.
Firstly, we have our toolboxes under the Tools list that are then dragged and dropped into the Tasks. When we drag the toolbox over, when can click on the Toolbox header to see the Tool Container. At this stage we won't be able to see the Show\Hide Test option so we need to activate it. To do this we right click on the Tool Container bar and turn it on:
Once on, we drop down the selection and go to the expression Name at the top. Drop this down and select the Is_STD expression:
This has now been set for the Task toolbox, but you left with the fact that users can still go through Tools>Tool Boxes and turn them on there. So, to make sure they can't access the tools in any way we must now go to the Tools window and go to each tool icon and add the Show\Hide Test option and set it to Is_STD. This is a bit of work to initially set up, but is worth the effort and once done only needs doing as tools are created:
To make sure we have set it up correctly, we can go back to our main cfg files and set:
Open MicroStation again and our tools should be hidden. The beauty of this with a good CAD build is that you can have the main variables set in the main cfg files and have them overwritten at the project or client level. this is what I've been doing and it makes life so much easier. The only thing you must remember to do is include your guidgnlib and the location of your Names Expression dgnlib in the client or project variables and you may find that custom client built will try and overwrite this location.
So, we've done our standard tools, but what else can we use this to Show\Hide?
Well, other than the standard tools I most commonly use this for apps\tools that are specific to application like Structural Modeller, InRods etc. In the custom cfg files, see build blogs, I add a variable:
Is_BSM = 1
If this is set, then all of the apps I have for Structural Modeller appear:
I also have an expression for my cell library tools, printing tools and much more. The sky is the limit as long as it works for you.