- Automatically execute commands upon file open [XFM project]


Users leveraging OpenCities Map XFM projects are able to execute key-in commands upon project open via definition of MS_GEOINITCMD as a macro (variable definition) within the XFM project, for a given XFM project workset.

Is there a likewise strategy for performing the same operations during file open events, similar to MS_DGNAPPS ?

OpenCities Map does not have an explicit variable for this purpose, but there are at least two strategies available to do so. 

For the examples below  we will use the delivered geo_example.xml XFM project schema, Dialogs  workset.

The VBA strategy (12 steps) is shown primarily for illustration, the XFM Method (6 steps) is simpler, expeditious, and the expected preference.  

 

 

via custom VBA:

Several MVBA examples and forum posts can be gleaned from searching Communities.Bentley.com and the wider internet.

For our purposes, the example at hand is AutoRun.mvba from the 2006 AskInga article: Run a VBA macro when opening or closing design files.

We suggest that you read the article and accompanying documentation thoroughly.

 

A00  Launch OpenCities Map without a project and load any design file.

A01 From the ribbon search tool (F4), type:  VBA , select ‘VBA Manager’ when presented to launch the VBA Manage:

 F4 > VBA Manager

A02 From the VBA Manager, open the AutoRun.mvba file from where you have extracted it.

A03 Select AutoRun from the list of available projects, set the Loaded toggle to engaged, and show the VBA Editor (pencil)


A04 From the VBA Editor’s project pane, expand Class Modules and locate module clsDGNOpenClose therein.  

The Module text should then display within the ‘code’ pane, for editing.

A05 Scroll through the code, or use CTRL+F to locate the OnDesignFileOpened procedure.

 

A06  Within the OnDesignFileOpened procedure, locate the series of example command instructions.

These are identified by the string:   CadInputQueue.SendCommand , and are followed by a keyin command parentheses enclosed.

 e.g. the first command encountered should be:

CadInputQueue.SendCommand "View on All"

 Modify this command, replacing View on All with your desired key-in or semi-colon separated key-in sequence.

 e.g.

CadInputQueue.SendCommand "Place Line;xy=0,0;xy=100,100"

 

VBA Editor: Code pane 

Modify additional commands within the module as desired, removing all remaining CadInputQueue.SendCommand statements thereafter.

Statements can be removed (text deleted) or commented out by placing an apostrophe [‘] at the beginning of the line in question.

 

A07 Locate the OnDesignFileClosed procedure.  Modify the section similarly to modify or remove undesired commands that will be executed upon closure of a file.

A08 Save changes to your MVBA code via File > Save…    , exit the VBA Editor and MicroStation session.

 A09 Launch the GSA and load your desired schema, select the Macros section of the desired workset, and add the following variables:


                MS_VBASEARCHDIRECTORIES    <              (your path to the extracted Autorun.mvba file, as from step A02)     * include trailing slash within the path

                MS_VBAAUTOLOADPROJECTS     <              AutoRun

 

Workset > Macros

 

 Your choice of Operator will vary to suit your configuration, in this case above, we prepend to preserve the existing definition and example project.

 

…apply the change

 

A10 Export the desired workset

  Workset > Export

 

A11  > Run the desired workset to test your work

 Workset > Run

 

 A12  when appropriate, File > Save or Save As within the GSA to preserve your changes to the XFM project

 

  

 

 

via XFM Method:

 

B00 Launch the GSA and open your desired XFM schema.   Select and expand the desired workset, ‘Methods’ node.

B01 …add new method group

 

 Add Menthod Group

 

 Add Method Group Name

B02 locate the newly added method group, and Add > Keyin Method

 Add Keyin Method

Name the method, and insert your desired key-in, or concatenated key-in string, then select OK to add the method. .

 Here we execute ‘history show’ (non modal) to launch the Design History dialog, followed by ‘dialog aboutustn’ to display the About MicroStation dialog (modal).

history show;dialog aboutustn

 

Keyin Method Keyin

 

B03 from the workset’s Macros node, add the variable MS_GEOXFM_OPENDGN_METHODS defined as: methodgroup|method name

Note the separating pipe [|] character:

 

                MS_GEOXFM_OPENDGN_METHODS          =              nelsmg|nelsdgnopen

 

 Workset > Macros...

 

 Apply the change

 

B04 go to step A10

 

 

 

Notes:

- As pertains to XFM Method and Method Group definition, these likewise could be placed within the All Users > Methods node of of the XFM project and then would be available globally, to all worksets.

The XFM method itself can of course be used to call an existing VBA, and remain the simpler route nonetheless. 

 

- Select variable definitions:

MS_GEOXFM_LOAD_METHODS  

Defines method to activate when MicroStation starts and the design file is loaded.              

MS_GEOXFM_LOAD_METHODS = SysProps|Initialize;MainMenu2|Open

 

MS_GEOXFM_OPENDGN_METHODS

Defines method(s) to activate when MicroStation opens a design file. Separate methods with a semi-colon.

MS_GEOXFM_OPENDGN_METHODS = DgnProps|Initialize 

MS_GEOXFM_OPENDGN_METHODS = SysProps|Initialize;MyProps|Initialize

 

* For a full list of XFM variables see the Bentley Map Customization Guide, as available within the documentation section of the Map SDK as ggapi.chm

The Map SDK is separate from the product installation set and downloaded separately.  The Map SDK is presently available only as the OpenCities Map Advanced SDK.

Prerequisites for the OpenCities Map Advanced SDK include:  OpenCities Map Advanced and version-suitable MicroStation SDK. 

OpenCities Map Ultimate users will need to install, though not necessarily initialize, Map Advanced to effect the SDK installation.