Original Article Date: January 2001
Updated: August 2006
Originally titled The Power of Keyins - Part 2 and published in the July 2000 issue of the MicroStation Manager Magazine, this tutorial covers how to create script files to streamline your workflows.
The ability to string keyins together is often referred to as a keyin script or action string. Whatever terminology you use, it's all a fairly easy to understand. In addition, by understanding the various options and components of action strings, you'lll be able to create very powerful scipts to streamline your workflow and minimize repetitive tasks. Let's get started!Action StringsWhatever MicroStation does when you activate a tool, menu item or function key can be referred to as an Action String. In other words, there is always some kind of keyin that executes a set of instructions when one of these items is selected. A great example of an action string is the F8 function key which toggles the display of construction elements on or off with this keyin: set construct toggle; selview all; update all where...set construct toggle Is the actual command to turn the construction elements on or off.selview all Instructs MicroStation to apply the keyin to all views.update all Updates all the views.
Action TypesThere are a variety of action types associated with tools, view controls, menu items and function keys. Note that some of these pre-date the current version of MicroStation and are shown with a (*).
A couple of things to point out with Action Types:If no type is specified, then MicroStation assumes that it will be a command entry keyin (E).For some terrific examples of action strings, take a look at the sample tablet menu in this file: ...\workspace\system\menus\dgn\v8menu.dgn. You'll want to navigate to the Command model and view the Command Text level.
Action Type OptionsIn addition to the Action Types, there are several options which can be used following the E, T or K action types. These options can be positioned anywhere in a multiple action string and must be followed with a semi-colon.
Stringing Multiple Keyins TogetherThere are two ways of stringing keyins together. The first is to simply keyin them all in on one line and separate each keyin with a semi-colon. This is typically referred to as an action string. The other is to use a script file which is described below. Seriously, that's all there is to it.Take this for example, this action string sets up your attributes and then selects the correct drawing tool.CO=3;LV=12;LC=2;WT=4;PLACE SMARTLINEWhere:CO=3 Sets the Active Colour to number 3LV=12 Sets the Active Level to 12LC=2 Sets the Active Line Style to 2WT=4 Sets the Active Weight to 4PLACE SMARTLINE Activates the Place Smartline toolAnd this example shows the use of the various action types. After setting up the active attributes, it places a circle with a 12 inch radius at a user-defined point:CO=7;LV=23;LC=0;WT=1;E,Place Circle Radius;T,12;M,Place Manhole;%d;nullWhere:CO=7 Sets the Active Colour to number 7LV=23 Sets the Active Level to 23LC=0 Sets the Active Line Style to 0WT=1 Sets the Active Weight to 1E,Place Circle radius A command keyin which activates the Place Circle Radius toolT,12 A terminated keyin that enters a radius of 12M,Place Manhole Displays a message in the status bar which reads “Place Manhole”%d MicroStation waits for a data point which defines the location of the manhole.NULL After the arc has been placed, MicroStation executes the NULL key-in so that no tool or view control is active.Script FilesSimply put, a script file is a list of MicroStation keyins stored in an external text file such as the following two examples. Note that in this case, you can enter each keyin on a separate line rather than stringing them all together on one line as described above.
Script files can be executed a number of different ways:
Whatever your need is for stringing multiple keyins together, there's no doubt that utilizing script files will allow you to improve upon your workflows. Have fun!
AskInga Article #37
You should post inquiries like that in the MicroStation community forum... communities.bentley.com/.../273.aspx
how do i place a cell with the active color?
ive used the command 'as=1;aa=0;lv=3;co=2;c,sdatumh' but this only sets the the level to 3 and the color stays 0 as it is in the cell library.
How, can I get some of this good information down loaded?
I have used scripts going way back - even combining them with special key-ins that InRoads adds to MicroStation (for station and offset and other similar things.)
In recent efforts, I have found that the ability to run a script from the command line within MicroStation is somehow less robust than earlier versions. In particular, I found it necessary to open a command window to determine the current directory within MicroStation and to then place my script in that folder for it to run. It seemed that any effort to include an absolute path to the script failed with no feedback.
I noticed in the above example RC=D:/CADD/PROJECTS/GENERAL.CEL The slach is / rather than \ after the d: is the D: the drive letter? and are the slach marks correct? I want to attempt to make a script and use it.