Writing Microstation (DGN) Text Nodes with FME

Pierre  Koelich
Pierre Koelich
  • Updated

Introduction

This article will cover how to write MicroStation text nodes, using multi-line text and text elements as list attributes. Text node features are point features and only have a single coordinate. Normally text nodes are used to group together lines of text into a single complex element. However, such text groups are handled by the igds_multi_text type and not by the igds_text_node type, which is used only for text nodes with no attached text.

The key to writing text nodes to MicroStation DGN is to define the text as a list attribute for each node. A list attribute in FME is a way to store multiple values for an attribute. Each value in the list becomes a line of text in the text node.

FME Format Attributes

Information is often stored in FME as format attributes. The format attributes for a text node are stored in a list called igds_text_elements{} and the list features must be associated with igds_type of igds_multi_text. Setting the igds_type ensures FME knows that these features are text nodes. Here you can see the igds_text_elements{} in a DGN Writer feature type:

For example, to create a text node feature representing pipeline IDs a user could to define:

  • igds_text_elements{0}.igds_text_string = Pipe173
  • igds_text_elements{1}.igds_text_string = Pipe617
  • igds_text_elements{2}.igds_text_string = Pipe941
  • igds_text_elements{3}.igds_text_string = Pipe833

They could also define any other format attributes, such as the x/y location, or the text font.
Additionally, the user must inform FME that this is a text node by setting:

  • igds_type = igds_multi_text

Step-by-Step Instructions

Part 1: Writing MicroStation Text Nodes - Basic Example

1. Add a Creator Transformer

Start FME Workbench. On the Start Page, select New Workspace to create a blank canvas.

Add a Creator transformer to the workspace.

The Creator transformer creates a feature to start a workspace using parameters supplied by the user. For more information on the Creator, please see the documentation.

Open the Creator Parameters and set the Geometry Object to Point. This will draw a point with coordinates 0,0.

Click ok to close the Creator Parameters. This will add one singular point that we can reference.

2. Add an AttributeCreator Transformer

Click on the canvas, type AttributeCreator, and double-click to select it from the list of transformers and add it to the canvas.

We are using these attributes to hard-code the writing of the text nodes.

3. Add a DGN Writer

Add a Writer to the workspace (from the Writer menu, select Add Writer)

Set the Format to Bentley MicroStation Design (V8)

Select a destination for the Writer Dataset.

Click Ok to add the writer to the canvas when prompted, set the Level name to Labels.

Run the workspace and view the results

Part 2: Writing MicroStation Text Nodes - Practical Example

The following example is more complex but is more realistic. It involves a source dataset of tree types. Each tree is listed under a postal address, and there can be multiple trees for each address.
The idea is to create a text node for each address that lists all of the trees.
The Workspace (Writing DGN Text Nodes Practical Example) can be found in the Files section of this article. 

1. Add a CSV Reader

Download PublicTrees.csv and Addresses.gdb

Start FME Workbench. On the Start Page, select New to create a blank canvas.

Add a Reader to the workspace (from the Readers menu select Add Reader).

Set the Format to CSV and set the Dataset to read the PublicTrees.csv

2. Add Esri Geodatabase Reader

Add a Reader to the workspace.

Set the Format to Esri Geodatabase (File Geodb Open API) and set the Dataset to read the Addresses.gdb

When prompted, select the PostalAddress from the Select Feature Types dialog.

3. Add a FeatureMerger Transformer

Add a FeatureMerger to the canvas by typing “FeatureMerger” to bring up the list of FME Transformers in the Quick Add Search. Select the FeatureMerger from the list of transformers by double-clicking or by using the arrow keys and the Enter key to add it to the workspace.

Once the transformer has been added, connect the CSV reader to the Requester port and connect the PostalAddress to the Supplier port.

Open the FeatureMerger Parameters, click the drop-down under the Requestor heading, click attribute value and select the Address Attribute.

Repeat the same steps for the Supplier and select PSTLADDRESS from the attribute list.

In this step, we are choosing a common attribute to join these two data sources together.

On the Merge Parameters, set the Feature Merge Type to Attributes and Geometry

4. Add AttributeCopier Transformer

Add an AttributeCopier transformer to the canvas by typing “AttributeCopier” to bring up the list of FME Transformers in the Quick Add Search. Select the AttributeCopier from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it to the workspace.

Once the transformer has been added, connect the Merged port from the FeatureMerger transformer to the AttributeCopier.

Open the AttributeCopier parameters, this will allow you to create a new attribute based on the original attributes that were read in.

Click the Input Attribute drop-down and select Species.

Click the Output Attribute box and type igds_text_string.

The igds_text_string is the attribute that the Microstation writer uses to create text on dgn.

5. Add a Counter Transformer

Add a Counter transformer to the canvas.

Once the transformer has been added, connect the Output port from the AttributeCopier transformer to the Counter transformer.

The Counter transformer adds a numeric attribute to a feature and assigns a value. Each subsequent feature passing through the transformer receives an incremented value.

Open the Counter Parameters. Set the Count Output Attribute to TreeNumber so for each species of tree that is at an address, the counter begins counting from 0 up.

Set the Counter Domain to the Address attribute from the drop-down, this will set the counter to read the Address each time.

6. Add CoordinateExtractor Transformer

Add a CoordinateExtractor to the canvas.

Once the transformer has been added, connect the Output port from the Counter transformer to the CoordinateExtractor transformer.

Open the CoordinateExtractor Parameters. The CoordinateExtractor is used to extract the x, y and z coordinates from the specified index into attributes. The default settings work in this case, we do not require a Z value.

7. Add an ExpressionEvaluator Transformer

Add an ExpressionEvaluator to the canvas.

The ExpressionEvaluator is used to calculate the x and y coordinates of each line in the text node.

The expression used in this case is:

@Value(y)-(8*@Value(TreeNumber))

This expression is used to create the y coordinate for each tree line at the address. The value 8 basically controls the spacing between each line.

8. Add an Aggregator Transformer

Add an Aggregator transformer to the canvas.

The Aggregator is used to combine feature geometries into heterogeneous or homogeneous aggregates. Alternatively, it combines feature attributes without any geometry. In this case, the features will be aggregated or combined by Address.

Set Group by to Address.

If a Count Attribute is entered, then an attribute with this name will be added to each output aggregate, containing the number of features that were combined to form the aggregate.

Enter NumTrees in the Count Attribute field. This will create an attribute with this name for each output aggregate.

Click the Generate List option. For List Name, enter igds_text_elements. Choose to add All Attributes to the list. By selecting this option, all the trees are aggregated into the same list by Address.

A limitation that exists with the Aggregator is that it removes the geometry. To counteract this, we can add a VertexCreator transformer.

9. Add a Counter Transformer

Add a Counter transformer to the canvas. This will give each node a unique ID number, which will increase incrementally as each feature passes through the transformer.

Open the Counter parameters and set the Count Output Attribute to igds_node_number

10. Add AttributeManager Transformer

Add an AttributeManager transformer to the canvas. The AttributeManager will create two Microstation Attributes, igds_text_size and igds_type, which are used to create text.

Open the AttributeManager parameters and scroll to the bottom of the list of attributes, click the <Add New Attribute> option, and type igds_text_size. Set the value of the text size to 5 in the Attribute Value Column.

Add another attribute, igds_type, and set the value to igds_multi_text

11. Add a Microstation Reader to the Canvas

From the Writer menu, select Add Writer. Set the Format to Microstation DGN and set the location of the Output.

Run the workspace, then view the results in MicroStation.

The attached template workspace, writing-dgn-text-nodes-practical-example.fmwt, runs through this workspace and has descriptive annotations and bookmarks.

Usage Notes

  • These examples are just two ways to create the required list. The second example is particularly useful when the number of labels for each text node is unknown. But any method of creating such a list will produce the correct results, and your scenarios may not need all of the transformers shown here (they may need more!).
  • Note that all lists in FME start at element 0 (zero). They do not start at 1 (one).
  • Features won't be visible in the FME Data Inspector unless they are given a color other than white. Use a DGNStyler transformer to do that.
  • The FME Data Inspector does not render igds_multi_text features as they would be in MicroStation. To see the text, you need to use the Split Multi-Text writer parameter. To see the attribute structure, you need to uncheck the Split Multi Text parameter (in which case, FME will display the node number, but the multi-text attributes will be preserved)

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.