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.
For each pair of paths below, use the one appropriate for your software (Promis.e vs. Bentley Substation).
Open Promis.e or Bentley Substation as the case may be.
Select Utilities > Macro > MicroStation BASIC from the main pull down menu.
On the Macros dialog, click the New button.
Enter the following into the text pane on BASIC Editor:Sub main MbeSendCommand "FIT VIEW EXTENDED 1"End Sub
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\
Close the dialog.
Close the software.
Using Notepad to add the following lines to untitled.ucf:MS_DGNAPPS > runmacroMS_DGNMACROS = pageopen.basThe untitled.ucf file is typically located in:C:\ProgramData\Bentley\Promise V8i\WorkSpace\UsersC:\ProgramData\Bentley\Substation V8i\WorkSpace\Users
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 runmacro.ma file to the \mdlsys\asneeded\ folder.
Run commands or BASIC macro when opening files
Run a VBA macro when opening or closing design files
Customizing the Interface - V8i
Keywords: zoom, extents, screen, maximize, all, script, macro, open, close