The MicroStation Programming Forum regularly receives postings asking some question about MicroStation Tag Sets and Tag data.

Here's the answer to questions posted to the Be Communities web site. See also our Tag Data Overview.

Q  How can I attach tags to multiple shapes in a DGN model?

A MicroStation's built-in tag tools are interactive: they want you to choose an element, then choose a tag set, then update tag values for each element that you want to annotate. If you want to add tags to a number of elements, that manual task is iterative and tedious, and therefore open to the usual human failings. ShapeTagger provides a answer: it adds tags to many elements in one go. There is no human interaction required. ShapeTagger is freeware.

Lorys Lea, an Australian MicroStation aficionado who often contributes to Be Communities, wrote this about ShapeTagger and AreaAnnotator:

It works brilliantly! I used ShapeTagger to tag the elements in bulk, and used AreaAnnotator to label the result. If things change we have to re-run the whole show got me out of a lot of work  … turn weeks of effort with possible errors into only a few days with massive reduction in errors, mostly through avoiding manual transcription and missed areas, fortunately it only needed reporting annually, but I was describing the manual process for basic user with no addons.

Q  How can I report the area of multiple shapes in a DGN model?

A Another freeware tool, AreaAnnotator™, measures areas automatically and updates tags on area elements. ShapeTagger uses AreaAnnotator to measure the area of shapes and complex shapes, and update the tags it has attached. Using MicroStation's built-in tag reporting tools you can create a report of shape and complex shape areas. LA Solutions' FlexiTable™ is easier to use than MicroStation's built-in tag reporting tools and is compatible with Microsoft Excel®.

Introduction

MicroStation Tags allow you to attach alpha-numeric attribute data to a graphic element. The effect is to build a database in your DGN model. MicroStation's tag tools and third-party products such as LA Solutions' FlexiTable™ let you create reports about tag data.

For example, you may have placed multiple cells in your DGN model, each cell representing a door. You want to tag each door in your DGN model with a unique ID. The ID tag provides a visual identity to a each member of a set of otherwise identical graphic elements. A report of the door tag set tells you how many doors exist in your model.

Untagged Shapes

The example here deals with shape elements rather than cells. We have multiple shapes, complex shapes or other objects that have area. We want to assign each area an ID and measure its area. The solution provided here is a MicroStation VBA macro called ShapeTagger. ShapeTagger attaches tags to multiple area objects then sub-contracts the task of measuring their area to another application, AreaAnnotator. The result is a set of annotated shapes, each showing a unique ID and area.

The VBA example here was inspired by the question: "How can I attach tags to multiple elements?" MicroStation's tools let you tag one element at a time. It's a repetitive and tedious task. We publish and provide here a VBA macro that will attach tags to multiple shapes in a DGN model.

For more information about MicroStation tags, look at the Microstation help file. Alternatively, if you're a VBA developer, consult the MicroStation VBA Help manual delivered with MicroStation. Also, see our Tag Data Overview for VBA developers.

ShapeTagger Dialog in MicroStation

Task Overview

A MicroStation user inherited a DGN file. The file contains a model having multiple shapes. Our user wants to annotate each shape with its measured area, and assign each shape a unique ID. Those requirement will make it easy to cross-reference a tag report with the DGN model.

We wrote a MicroStation VBA macro to help speed up his task. The macro performs the following …

  1. Verifies that the DGN file includes a named tag set definition
  2. Verifies that the DGN file includes a named level
  3. Scans the DGN model for shape elements on the designated level
  4. For each shape element …
    • Attaches tag elements from the designated tag set
    • Provides a unique numeric ID
  5. Loads MDL application AreaAnnotator
  6. Sends AreaAnnotator its command to synchronise area measurements with the tag values

After the macro has completed, the shape elements are annotated with a unique ID and area …

Tagged Shapes

VBA Macro Usage

If you just want to use this macro, download the ZIP file, then unpack it and copy the ShapeTagger.mvba file to a well-known MicroStation VBA folder. A suitable folder is ..\Workspace\Standards\vba.

How to use the ShapeTagger VBA macro …

  1. Start MicroStation and open a DGN model containing shapes that you want to annotate
  2. The VBA macro is hard-wired to look for shapes on a level named Shapes
    • If you don't have a level named Shapes, either
      1. Create a level named Shapes and create or copy some shapes to that level

        or

      2. Edit the VBA macro and change the name of the level it's looking for to one that matches your DGN file
  3. Ensure that you have a tag set named zones defined in your DGN file
    • The zones tag set is documented in the AreaAnnotator™ help file
    • If you don't have a tag set named zones
      • Create a tag set named Shapes and create or copy some shapes to that level
      • The sample DGN file contained in the download has the zones tag set defined
  4. Run the macro using MicroStation keyin:
    vba run [ShapeTagger]modMain.Main

If everthing is set up correctly, you will see shape elements annotated with tags. Shapes on other levels remain unaffected. ShapeTagger does the work of finding shape elements and adding tag elements to each shape. Once it's finished scanning your DGN model, it calls on AreaAnnotator to perform its measurements and update the DGN model.

MicroStation has built-in tools for tag reporting. Third-party products, such as LA Solutions' FlexiTable™, provide other ways to gather tag information. We created the screenshot below by using FlexiTable to harvest the tag data, then exporting in Microsoft Excel®. The screenshot shows the report in an Excel worksheet …

ShapeTagger report displayed in Excel

Notes :

  1. The tag ID is in the worksheet's column I
  2. The Element ID in the first column is MicroStation's internal, unique, element ID
  3. The Area column is the actual area measurement in the DGN model's master units (mu)
    • In this example, the master units are metres and the area is measured in square metres (m²)
  4. The Area Format column shows AreaAnnotator's work. AreaAnnotator has formatted the precise area measurement to a more manageable m² with less decimal precision
  5. The Perimeter column is the actual perimeter measurement in the DGN model's master units (mu)
  6. The Linear Format column shows AreaAnnotator's work. AreaAnnotator has formatted the precise perimeter measurement to a more manageable metres (m) with less decimal precision

VBA Macro Deconstructed

This section is for VBA developers. It explains the internal structure of the VBA macro.

The macro illustrates several key topics …

Scan Model for Shape Elements

The VBA code to scan the DGN model is conventional. It's similar to other examples that you will find on this web site and in the MicroStation VBA help manual.

Attach Tag Elements to each Shape

The VBA code to attach elements is conventional. It's similar to other examples that you will find on this web site and in the MicroStation VBA help manual.

Invoke AreaAnnotator to measure each Shape

The macro does its work, which is to attach tags to each shape element. It doesn't take measurements of each area, because AreaAnnotator is explicitly designed for that task.

The macro checks to see if AreaAnnotator is already loaded, and if not queues the mdl load annotator command.

The macro queues the command Annotator ID Enable Off. That command tells AreaAnnotator not to provides its own IDs.

The macro queues the command Annotator Synchronise All. That command tells AreaAnnotator to find any component tagged with the zones tag set and re-measure its area and perimeter. AreaAnnotator updates the tags with the new measurements.

How to Obtain ShapeTagger

ShapeTagger is bundled with AreaAnnotator. AreaAnnotator and ShapeTagger are freeware.

Visit the download page to register your interest in AreaAnnotator and ShapeTagger then download the installer.