Writing Microstation (DGN) Tags with FME

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2020.0

Introduction

Non-spatial attribute information can be attached to a DGN element as tags, a Microstation feature. A simple parameter inside FME can help to write FME attributes as MicroStation tags. Tags can be written to MicroStation design files by creating a series of format attributes that define tags and tag sets, as well as user attributes that store tag values.

Reading MicroStation tags using FME is covered in this article.

 

Step-by-Step Instructions

Writing Tags: A Basic Example

1. Add MapInfo Reader

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 MapInfo and set the Dataset to read the Parks.tab

1-add-mitab-reader.png

 

2. Add DGN Writer

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

Set the Format as Bentley MicroStation Design (V8)

Set the Dataset as Written Tag.dgn in a file location of your choosing.

Set the Level Definition to Automatic

2-add-a-dgn-writer.png

 

When adding a DGN Writer to a workspace, the parameters dialog has a Write tags parameter with the option of Yes or No.

Click the Parameters button and set the Write Tags setting to Yes then click OK.

2-dgn-writer-paramaters.png

 

Click OK, this will open the Feature Type dialog box, call the Level Name: Parks and click OK

2-dgn-feature-type-paramaters.png

 

The same parameter exists in the Navigator window in an existing workspace:

2-write-tags-navigator.png

 

3. Run Workspace

The user should then set up the DGN Writer feature types, using any method they like, with the required attribute schema. Run the workspace.

3-run-workspace.png

Then - assuming Write Tags is set to yes - when the workspace is run the attribute information from the source features will be written as a set of tags to the MicroStation dataset:

results-microstation-tags.pngThe tagset here is named "Parks" because that is the name of the FME feature type.

 

Writing Tags Through Attributes

When more than one tagset is required, then tags can be defined using format attributes. These attributes tell the Writer which attributes should be used and to which tag set they should belong. The attributes are as follows:

igds_tag_names{}
<tag name>.tagset_name
<tag name>.tagtype
<tag name>.prompt
<tag name>.display
<tag name>.default_value
<tag name>.x_offset
<tag name>.y_offset
<tag name>.z_offset


For example, you might define attributes as:

igds_tag_names{0} = ParkName
igds_tag_names{1} = ParkArea
ParkName.tagset_name = Leisure
ParkArea.tagset_name = GroundsMaintenance

This would create two tagsets (Leisure, GroundsMaintenance), each with a single tag (ParkName, ParkArea)

 

Writing Tags: An Advanced Example

The following example writes a set of parcel boundaries with two different tagsets; one for general parcel information, one for ownership information. Download the template Writing DGN Tags Example, open with FME Workbench, and inspect it:

workspace.png

Notice that the first section of the workspace reads the parcel data, which has some basic parcel information, and merges in ownership information from an Excel spreadsheet.

The second section bookmarked "Define Tags" consists of five transformers that carry out the creation of attributes to define the tags.

 

1. Add MapInfo Reader

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 MapInfo and set the Dataset to read the Parcels.tab (Downloads section)

1-add-mapinfo-reader.png

 

2. Add an Excel Read

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

Set the Format as Microsoft Excel.

Set the Dataset to read Parcels.xls

2-add-excel-reader.png

 

Choose the parcelOwners Feature type when prompted.

2-pacelowners-sheet.png

 

3. Add a FeatureMerger

Start typing 'Feature' on the Canvas and select the FeatureMerger transformer from the Transformer List to add it to the canvas. This will merge the two datasets based on a common attribute, in this case, PARCEL_ID.

Connect the MapInfo parcels Feature Type to the Requestor Port.

Connect the Excel parcelOwners Feature Type to Supplier Port.

Open the FeatureMerger Parameters, set the Requestor to read the PARCEL_ID from the MapInfo parcels Feature Type, and set the Supplier to read the PARCEL_ID from the parcelOwners Feature Type.

3-add-featuremerger.png

 

4. Add an AttributeCreator

Add an AttributeCreator to the canvas and connect the Merged port of the FeatureMerger to the AttributeCreator.

Create each of the following attributes.

We set up a list of attributes we would like to see in the design file, which equates to the tags being created:

igds_tag_names{0} PARCEL_ID
igds_tag_names{1} AREA
igds_tag_names{2} PERIMETER
igds_tag_names{3} Owner
igds_tag_names{4} OwnershipSince

 

We also assign each tag to a tagset, which allows us to create more than one tag set:

PARCEL_ID.tagset_name        ParcelData
AREA.tagset_name             ParcelData
PERIMETER.tagset_name        ParcelData
Owner.tagset_name            OwnerData
OwnershipSince.tagset_name   OwnerData

 

We define the tag data types (where 1 is a string, 3 is an integer, and 4 is a real number):

PARCEL_ID.tagtype        3
AREA.tagtype             4
PERIMETER.tagtype        4
Owner.tagtype            1
OwnershipSince.tagtype   3

 

For PARCEL_ID, we also create a set of optional attributes, which control whether the tag is displayable and how it is placed relative to the feature origin:

PARCEL_ID.display       yes
PARCEL_ID.height         5
PARCEL_ID.justification  7

 

The AttributeCreator Parameters should look like this.
4-add-attributecreator.png

 

5. Add a CenterPointExtractor

Add a CenetrPointExtractor to the canvas and connect AttributeCreator Output port to the CenterPointExtractor. This transformer retrieves the x, y and z coordinates of the center point of the Parcels bounding box.

Set the Point Extraction Mode to Any Inside Point.

5-add-centerpointextractor.png

 

6. Add a CoordinateExtractor

Add a CoordinateExtractor to the canvas and connect the CenterPointExtractor to the CoordinateExtractor.

Open the CoordinateExtractor parameters. Set the Mode to Specify Coordinate set the Default Z Value to -9999. In this case, we do not need to worry about the z coordinate as we are using 2D data.

6-add-coordinateextractor.png

 

7. Calculate the x offset using an ExpressionEvaluator

When <tag_name>.display is set to 'yes' we also have to set offset attributes, to define where that tag will be displayed.

Add an ExpressionEvaluator to the canvas and connect the CoordinateExtractor output port to the ExpressionEvaluator.

Set New Attribute to PARCEL_ID.x_offset.

Use the following Arthimithic Expression.

@Value(_inside_x)-@Value(_x) 

7-add-an-expressionevaluator.png

 

8. Calculate the y offset using an ExpressionEvaluator

We are going to repeat the previous step this time, calculating the PARCEL_ID y offset.

Add another ExpressionEvaluator to the canvas and connect the first ExpressionEvaluator output port to the second ExpressionEvaluator.

Set New Attribute to PARCEL_ID.y_offset.

Use the following Arthimithic Expression.

@Value(_inside_y)-@Value(_y)

8-add-an-expressionvaluator-y.png

 

9. Add a DGN Writer

Finally, add a Bentley MicroStation Design (V8) writer to the canvas. Choose a location for the output data. Open the Writer Parameters ensure to set the Write Tags to Yes

Also, ensure that the Seed File (V8 only) is set to read the seed2d_m_v8.dgn. Click Ok.

9-dgn-writer-parameters.png

Run the Workspace.

 

Results

The result is a set of tags in MicroStation:

10-results.png

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.