Run key-ins when a page is opened

 Product(s):Promis.e, Bentley Substation
 Area:PowerPlatform Support

How can I execute commands whenever a page is opened?


This article describes how to run key-in commands whenever a page is opened in standalone Promis.e or Bentley Substation. This is done by using MicroStation BASIC and MicroStation macros containing the desired key-ins. Many Promis.e and Bentley Substation tools in addition to platform tools can be invoked by key-ins.

To demonstrate the technique, the software will be configured so that the Fit View tool will be invoked when a project page (or any DGN file) is opened. In previous versions the software performed a Fit View operation automatically. By request, this was removed in SELECTseries 8, but some users would still like Fit View to happen automatically. The example can be adapted to other commands, and the macro could contain multiple commands.

Note: Fit View is used as an example for this document. An easier method of enabling the Fit View behavior in Promis.e V8i SELECTseries 8 is to set the "Fit View" on page open check box on [[Options]] > User Options > Viewing Preferences.

Steps to Accomplish

For each pair of paths below, use the one appropriate for your software (Promis.e vs. Bentley Substation).

  1. Use Windows Explorer to copy to the \mdlsys\asneeded\ folder.

    The file is typically located in:
    C:\Program Files (x86)\Bentley\promise V8i\Promise\mdlapps\
    C:\Program Files (x86)\Bentley\Substation V8i\Substation\mdlapps\

    and should be copied to:
    C:\Program Files (x86)\Bentley\promise V8i\Promise\mdlsys\asneeded\
    C:\Program Files (x86)\Bentley\Substation V8i\Substation\mdlsys\asneeded\
  2. Open Promis.e or Bentley Substation as the case may be.

  3. Select Utilities > Macro > MicroStation BASIC from the main pull down menu.

  4. On the Macros dialog, click the New button.

  5. Enter the following into the text pane on BASIC Editor:
    Sub main
       MbeSendCommand "FIT VIEW EXTENDED 1"
    End Sub

  6. Select File > Save on the BASIC Editor dialog. Name the macro pageopen so a pageopen.bas file is created.
    Note where the macro is saved if it is to be distributed to other users. It is typically stored in:
    C:\ProgramData\Bentley\Promise V8i\WorkSpace\Standards\macros\
    C:\ProgramData\Bentley\Substation V8i\WorkSpace\Standards\macros\

  7. Close the dialog.

  8. Close the software.

  9. Using Notepad to add the following lines to untitled.ucf:
    MS_DGNAPPS > runmacro
    MS_DGNMACROS = pageopen.bas

    The untitled.ucf file is typically located in:
    C:\ProgramData\Bentley\Promise V8i\WorkSpace\Users
    C:\ProgramData\Bentley\Substation V8i\WorkSpace\Users

  10. Start the software.

To distribute the functionality to other users, distribute the pageopen.* files, the untitled.ucf file (or append to theirs), and copy the file to the \mdlsys\asneeded\ folder.

See Also

Run commands or BASIC macro when opening files

Run a VBA macro when opening or closing design files

[[Customizing the Interface]]

 Original Author:Matt_P

Keywords: zoom, extents, screen, maximize, all, script, macro, open, close