Writing Microstation (DGN) Text Nodes with FME

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2020.0

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.
 

Step-by-Step Instructions

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:

dgn-format-attributes.png

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

 

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 is a way to add features to a workspace by using parameters supplied by the user. It can be very useful, like in this case, where we are trying to prove a concept. For more information on the Creator, please see the link to the documentation.
 

2. Edit the Creator Parameters

Open the Creator Parameters and set the Geometry Object to Point.

Click ok to close the Creator Parameters.

This will add one singular point that we can reference.

1-creator-parameters.png


3. Add an AttributeCreator Transformer

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

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

2-attributecreator-parameters.png


4. 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.

 

Results

This results in a single text node:

basic-example-results.png

A single text node viewed in Microstation.

 

Writing MicroStation Text Nodes: A 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 Downloads section of this article. 

 

1. Add a CSV Reader

Download PublicTrees.csv and Addresses.gdb

Start FME Workbench. On the Start Page, select New Workspace 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

1-add-csv-reader.png
 

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

2-add-gdb-reader.png

When prompted, select the PostalAddress from the Select Table dialog box.

2-add-gdb-reader-select-table.png
 

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 Geometry

3-add-featuremerger-parameters-address-attriute.png
 

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, thus 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 drop-down and type igds_text_string.

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

4-attributecopier-parameters.png
 

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 Name to the Address attribute from the drop-down, this will set the counter to read the Address each time.

5-counter-parameters.png
 

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 an x value.

6-coordinateextractor-parameters.png
 

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.

7-expressionevaluator.png

 

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, will Aggregate or combine the features 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 NumTress 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 that 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.

8-aggregator-transformer.png
 

9. Add a Counter Transformer

Add a Counter transformer to the canvas, this will be used to 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

9-counter-parameters.png
 

10. Add AttributeManager Transformer

Add an AttributeManager transformer to the canvas.

The AttributeManager will be used to create two Microstation Attributes that are used in the creation of text, igds_text_size and igds_type.

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

10-attributemanager-parameters.png


11. Add a Microstation Reader to the Canvas

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

Set the Format to Microstation DGN and set the location of the Output.

 

Results

Run the workspace, then view the results in Microstation.

results.png

 

Notes

  • These examples are just two ways to create the required list. The second example is particularly useful when there is an unknown number of labels for each text node. 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 (it may need more!)
  • Note that all lists in FME start with element number 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 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. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.