Introduction
An item type is a user-defined, non-spatial set of properties that replaces tags in Microstation V8.
You can write FME attributes as item types by following a few steps, which will be outlined below. Similar to tags, you have to create a series of format attributes that will define item names and their data types.
More information about how FME handles item types can be found here.
Step-by-Step Instructions
Reading Item Types
The DGN V8 reader in FME Workbench is able to read in item types from a DGN file. This example will showcase how these item types are read in and can be manipulated using FME.
1. Add DGN Reader
Start FME Workbench. On the Start Page, select New Workspace to create a blank canvas.
Add a Bentley MicroStation Design (V8) Reader to the workspace (from the Readers menu select Add Reader).
Select Water_distribution_mains.dgn file as the Dataset, and click on Parameters.
Enable Read XAttributes and Item Type attributes (V8 only), we can leave all other parameters as default.
In the Select Feature Types(Level) select Level1 and click OK.
On the canvas, expanding the attributes on the reader feature type reveals that the item types were read in by the reader.
Single-click the Level1 reader feature type and click on View Source Data:
The item types are shown as attributes in the Visual Preview window.
In the Feature Information window, note the following:
- Individual item types and their data
- A list attribute containing a list of the individual Item Type names
- Further information on each item can be found here, specifically the <item type>.<property>.type, which tells us what data type(string, integer, etc.) this item property has.
2. Using the Data
The data is ready to use. For example, you could configure an AttributeFilter transformer to filter out water mains that are made of a certain type of material:
Writing Item Types: A Basic Example
In this basic example, we will extract the polygons from a MapInfo file containing parks in Vancouver, BC, and writing two attributes, the Park Name, and the Visitor Count from the file as Item Types, to a Microstation V8 DGN file.
1. Add MapInfo TAB Reader
Start FME Workbench. On the Start Page, select New Workspace to create a blank canvas.
Add a Reader to the workspace.
Set the Format to MapInfo TAB (MITAB) and set the Dataset to read the Parks.tab
Inspecting the data will show a series of park polygons with rows containing attributes, some of these we will write to a DGN file.
2. Add an AttributeCreator Transformer
Type AttributeCreator on the canvas to bring up the quick add menu and add the transformer to the workspace.
Connect the Parks port to the input port of the AttributeCreator. Set the parameters as shown in this table:
| Output Attribute | Value | Type |
|---|---|---|
| igds_item_names{0} | Parks | (leave as default) |
| Parks.Name | ParkName | (leave as default) |
| Parks.Name.type | 1 | (leave as default) |
| Parks.TreeCount | TreeCount | (leave as default) |
| Parks.TreeCount.type | 3 | (leave as default) |
3. Add DGN Writer
Add a Writer to the workspace.
Set the Format as Bentley MicroStation Design (V8)
Set the Dataset as parks.dgn in a file location of your choosing.
Set the Level Definition to Automatic.
In the Feature Type dialog, set the Level Name to Parks.
Click OK, and then OK again. Connect the output port of the AttributeCreator to the Parks writer feature type.
Run the workspace and inspect the results either in Microstation or Bentley View.
You can see that in the properties, the two attributes from the MapInfo file that have been written as item types under the Parks item.
Writing Item Types: An Advanced Example
The following example writes a GeoJSON dataset of trees as cells to a DGN file, then adds the attributes from the file annotations and item types to the trees.
1. Add GeoJSON Reader
Start FME Workbench. On the Start Page, select New Workspace to create a blank canvas.
Set the Dataset to important_trees.json and click OK to add it to the workspace.
2. Add an AttributeKeeper Transformer
Add an AttributeKeeper transformer to the workspace.
Connect the GeoJSON reader to the input port of the transformer. In the parameters, click on the ellipsis button next to Attributes to Keep.
Select the attributes:
- HERITAGE_TREE_NO
- SIGNIFICANT_TREE_NO
- SITE_NAME
- TREE_SPECIES
3. Create Annotations
Add an Offsetter transformer to the workspace, connect the output from the AttributeKeeper transformer to the input port, and set both the X Offset and Y Offset to 10.
Add a LabelPointReplacer transformer to the workspace. Connect the Offset port from the Offsetter to the Input port. Open the parameters and set the Label Height to 18, then click on the ellipsis button next to Label.
Use the following expression in the text editor, once it is set, click OK and OK again.
@Value(TREE_SPECIES)
@Value(SIGNIFICANT_TREE_NO)
@Value(SITE_NAME)
4. Create Item Types
Add a BulkAttributeRenamer transformer to the workspace. This one will change the case of the attributes. Connect output from the AttributeKeeper to its input. Set Action to Change case, the Mode to Rename, and Case Change Type to Full Title Case, click OK:
Add another BulkAttributeRenamer transformer to the workspace and connect it to the previous BulkAttributeRenamer. Set the Action to String Replace, Mode to Rename, Text to Find to an underscore(_), and leave String as blank. This one will remove all the underscores from the workspace. Click OK:
Add a third BulkAttributeRenamer transformer to the workspace. Connect it to the BulkAttributeRenamer_2t. This one will add a Trees. prefix to all attributes, so Microstation can recognize it as a part of an item type. Change Rename to Selected Attributes, then click the ellipsis button next to Selected Attributes. Select HeritageTreeNo, SignificantTreeNo, SiteName, and TreeSpecies. Click OK
Then set Action to Add String Prefix, Mode to Keep Original Attributes, and String to Trees.:
Add a fourth BulkAttributeRenamer transformer to the workspace. Connect it to the BulkAttributeRenamer_3. This one will add a .type suffix to all attributes, and keep the old ones. The data type(string, integer) will be written here. Set Rename to Selected Attributes. Then select the entire Trees attribute, click OK:
Then set the Action to Add String Suffix, Mode to Keep Original Attributes, and String to .type:
From here, click run to this.
Inspecting the feature information on any of the rows in Visual Preview will show something like this:
5. Add an AttributeManager
Add an AttributeManager transformer, open the parameters, and set them as follows:
- Add a new attribute called igds_item_names{0} and set its value to Trees. Microstation will now associate all attributes with the prefix Trees. with the Item_Type Trees.
- Set the values for the attributes named Trees.<property name> as the attribute values from the GeoJSON file.
- Manually set the values for the attributes named Trees.<property name>.type as shown below in the screenshot. 1 in this case denotes a string data type, and 3 denotes an integer data type.
- Remove the attributes without the Trees. prefix
Inspecting the feature information on any of the rows in the data inspector will show something like this:
6. Create Cells
Add a DGNStyler to the workspace. Connect the output of the AttributeManager to its input.
Open the parameters. Follow these steps:
- Click the ellipsis button next to cell library file and navigate to your FME installation directory, find the folder named design and select default_v8.cel (Default: "C:\Program Files\FME\design\default_v8.cel"). This is a file containing premade cells that will be used to show the trees on the map.
- Click the ellipsis button next to Cell Name and select the cell named TREE
- Set the Cell Size to Master Units, and the X and Y to 20.
7. Add a DGN Writer
Add a DGN writer to the workspace, set Dataset, and then click OK:
In the Feature Type parameters, set the Level Name to Trees and leave everything else as default, click OK:
Duplicate the writer by pressing Ctrl + D or right-clicking the reader and selecting duplicate. Then set the Level Name to Trees_Annotations:
Now connect the DGNStyler to the Trees writer feature type, and the LabelPointReplacer to Trees_Annotations writer feature type.
Click Run to run the entire workspace.
8. Results
Opening the results in the FME Data Inspector shows the tree cells and the annotations:
Opening the results in Bentley View, we can also look at the individual item types:
Data Attribution
The data used here originates from open data made available by the Cities of Vancouver and Surrey, British Columbia. This article contains data licensed under the Open Government License - Vancouver and the Open Government License - City of Surrey.