Batch Process Series Part 2: It’s All About the Key-in(s)

Key-ins are what drive the Batch Process utility. Adding key-ins to your command file allows you to direct the set of actions that will be applied and the order in which to apply them. It is possible to use MicroStation key-ins directly, run a MicroStation VBA Macro or an MDL application through a key-in, and potentially integrate key-ins from a specific vertical application if that application is also running (such as those commands associated with a specific PowerPlatform).

You may ask yourself, “How do I find the key-ins to use?” Locating the desired key-ins can range from quite easy to difficult, or not possible to locate at all if a key-in doesn’t exist for what you are trying to do. Let’s look at a couple of possibilities.

The Key-in Browser

The Key-in browser is probably the first place most will go to start looking for key-ins…it is logical to look for key-ins in a “Key-in” dialog. In the MicroStation CONNECT Edition the Key-in browser can be opened several different ways:

  • From the Primary ribbon group in the Home tab of the Drawing workflow
  • On the keyboard press <Enter>
  • From Search Ribbon (search for Key-in)

 Let’s say that you want to remove any unused levels in a set of DGN files. In the Key-in dialog it is reasonable to begin searching for key-ins that start with the word delete.

Begin by typing in a few characters from the word delete. The display of key-ins is alphabetical…dropping to the first word (key-in) that begins with the characters supplied. You can see “delete” in the list within the first column.

Next, in the second column, scroll down in the list. Here you see displayed the key-ins that can be used to delete various things, including unused items. Pick “unused” in this column.

In the third column you will see displayed the individual types of unused items that can be deleted, including levels. The key-in for deleting unused levels from within the active DGN has just been discovered!

But not all key-ins are quite that logical to locate, with many key-ins having existed for many years and software generations.

Note: Not every command has an equivalent key-in. You may occasionally run into a situation where a key-in for what you are trying to do is not available

 

Review an Existing Tool

Another way to discover a key-in is to look at existing tools and interface items through the customize dialogs (Customize and Customize Ribbon). From Search Ribbon, type in the first few characters of the word “customize”, picking Customize from the search results shown. This opens the Customize dialog.

In the left pane of the Tools tab, expand Application Tools > MicroStation. Here you will find many of the tool boxes and tools found within MicroStation.

Pick a tool within a tool box. Once selected, you will see the Properties for that tool, including the Command Data. The Command Data is where the key-in for the command con be found. In the following illustration, Fit View has been selected. As can be seen in the Key-in field, the command to fit the view is “fit view extended”.

Finding a Key-in Using the Bentley Macro Recorder

Another way of attempting to locate a key-in is to record a command (or sequence of commands) using the Bentley Macro Recorder. The Bentley Macro Recorder provides a set of features to allow non-programmers to record and play back macros. Once recorded, the macro is saved as a .bmr file and stored at the location identified through the MS_MACRONEWFILEDIRECTORY configuration variable.

From the Utilities tab in the Drawing workflow, locate the Macros ribbon group. As was done in the previous example, an attempt will now be made to locate the “fit” command.

  1. To begin recording a new macro, from Macros pick Record. The recorder will now record any action that is performed.
  2. From the View tools, pick Fit View.
  3. From Macros, pick Stop.
  4. The create Macro dialog opens, prompting for a name for the new macro. In Name, type the name for the new macro and pick Save.
  5. To view what was recorded by the macro, select the desired macro from the list and pick the command: Edit the currently selected macro

      

The macro editor is then opened with the recorded command displayed. What is seen here differs from that seen earlier when viewing the Fit View tool through the Customize dialog. When the macro was recorded, the number “1” was appended to the key-in: FIT VIEW EXTENDED 1

The addition of the “1” is used to designate which view window the command should be applied to. The key-in could be modified to specify any of the view windows 1-8:

  • Key-in for view window 1: FIT VIEW EXTENDED 1
  • Key-in for view window 2: FIT VIEW EXTENDED 2
  • Key-in for view window 7: FIT VIEW EXTENDED 7

 

Note: The sequence that was recorded by the Bentley Macro Recorder could have been much more extensive than the example seen here. The macro could then be used to identify potential MicroStation key-ins or the macro could be ran as a macro file (.bmr file) using a key-in within a command file.

 

Additional useful key-ins

The following is a list of some additional key-ins that you may find useful when creating a command file, some of which are illustrated in the examples that may be downloaded from this blog post. Remember, when it makes sense to do so, more than a single command can be issued from a line within the command file. A string of commands is composed of individual key-ins (on a single line) that are separated by a semicolon. Additional useful key-ins include:

  • selview 1: Used to identify a view window in which to perform an action.
  • filedesign: Performs a “save settings”.
  • macro play MacroNameHere: Used to run a macro from MicroStation.
  • XY=xCord,yCord,zCord: Used to provide a coordinate (such as a data point) where xCord is the “X” coordinate value, yCord is the “Y” coordinate value, and zCord is the Z coordinate value.
  • choose all: Used to select all elements in the model.
  • choose none: Used to deselect all elements in the model.
  • dgnlib update all: Updates all “local” definitions in a DGN to match the parent definitions stored in the configured DGNlibs.
  • order element front: Used to bring elements to the front. Works well with a selection set.
  • place smartline: The “place” command is used to activate many of the standard placement tools used to create elements. The word “smartline” can be replaced with the name of other tools (i.e. block, arc, etc.) and can have additional parameters applied to the command based upon the specific tool being called (the Key-in browser is a great place to find the additional parameters).
  • set acsdisplay on: Used to enable the display of the ACS in a view.

 

These are certainly not the only key-ins that can be used in command files for the Batch Process utility. There are multitudes of additional useful key-ins that can be applied to meet your needs.

The Batch Process utility is a powerful tool in your Bentley toolbox. The next time you need run a sequence of commands give it a try!

 

Happy LEARNing!