- Convert text to XFM and propagate text string to shapes using VBA

This tutorial discusses converting plain MicroStation text to usable XFM features and propagate the text string value to polygons.  This is accomplished by using two lightweight macros that are available for your use    




First of all, a Bentley Map project schema is created that includes two features:  MapTile as a polygon and MapTileText as a point-text feature.  Each has a text string property named Label  which will be the placeholder for the text string.

The design file is a grid of map tiles that are labelled accordingly.   The map tiles and labels are on separate levels named:  MapTiles and MapTileText. 

When the design file is opened with the Map project as the active workspace, the MicroStation elements are identified as inferred features.

Load the  VBA named text2xfm and run the macro ModMain.run.  The Input Feature/Level will be the existing text in the design file, and the Load Property will be a text property of the feature definition.  In order for this macro to work as intended, ensure that the level of the text matches the level of the text feature in the project schema.  When processed, the text will change to green and be recognized as XFM native features. 

As well, when Analyze Feature or Edit Feature is used, the dialogs show that the original text string is now a business property of the text feature.

The next step in this workflow is to propagate the label from the newly created text features to the existing map tile shapes.  To do that, the map tiles must first be promoted to XFM features using the Bentley Map Promote tool that's part of the map schema.  When promoted, the shapes will change colour to red.  Note that the Label property is left blank at this time.

Load the second macro named centroids_text_to_shape.mvba  (it will load as centroid3 in the VBA Project Manager).    This macro requires that the text features are centroids in closed shapes.  This means that they need to be completely within the boundaries of the shapes in order for the macro to be successful.  The dialog of the macro enables you to select the polygon and centroid (text) features as well as the property to copy.  Clicking Copy Business Properties will execute the macro and in this example 15 centroids are processed.

Reviewing a map tile shows that the Label property is now populated with the text value of the centroid and is ready to export to SHP or be used in a mapping project.

The attached zip file contains the geospatial project, the design file, both macros and a PDF of this article. 


Disclaimer:  These applications are supplied as-is and do not come with support. Bentley Systems Inc., and the author of these programs assume no liability for damages direct, indirect, or consequential, which may result from the use of these programs. Use these application at your own risk.

Related Links:  https://communities.bentley.com/products/geospatial/desktop/f/bentley-map-forum/127584/promote-a-text-to-a-feature-point-text/388622#388622