FME Version
Files
-
- 80 KB
- Download
Introduction
Text styles are named sets of text attributes, such as font, width, height, and color, that allow you to place text within a DGN model in a consistent and automated manner. Text Styles within Bentley Microstation can be set through a number of different methods in FME and can also utilize a Template file to define the Text Style in Microstation. The attached workspace is an example of setting MicroStation text styles in Esri Shapefile to MicroStation DGN V8 translation.
Source Data
The source Shapefile datasets contain
- Vancouver street segments with street names and street use types (residential, arterial, etc.) stored as attributes and
- Vancouver park polygons with park names stored as attributes.
This is the source data displayed with the FME Data Inspector:
Workspace Summary
During translation, some of the street segments are labeled with street name labels. The text style of each street name label depends on the street use type. Also, parks are labeled with park name labels, which are placed at park polygon center points.
Step-by-Step Instructions
1. Read source Shapefile datasets
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 Esri Shapefile and the Dataset to read VancouverStreets_small.shp. Add a second Esri Shapefile Reader to the workspace, and the Dataset to read ParkPolygons_small.shp
2. Write VancouverStreets into DGN
DGN Vancouver Streets Writer.
Add a Bentley MicroStation Design (V8) writer to the canvas. Choose a location for the output data.
Street segments are written into the destination DGN with no styling. They are part of the base map. This task is not related to text styling.
To achieve the same style as this article you can download the Seed file that we used from the downloads section. In the DGN Writer parameters click the ellipsis next to Seed File (V8 Only) and locate the downloaded Seed file.
Vancouver Streets Results.
3. Prepare street segments for labeling:
In the source dataset, there are too many street segments to label them all. To avoid multiple overlapping labels for the same street and labels with wrong rotation:
-
street segments are
-
generalized (vertices that are not needed are removed) with Generalizer;
-
chopped into two vertices long segments with Chopper;
-
-
only the longest segment for each street is then kept using LengthCalculator, Sorter, and DuplicateRemover;
-
in addition, segments longer than 300m are kept as well.
4. Removes Unnecessary Vertices
Add a Generalizer transformer to the canvas and connect it to the VancouverStreets_small reader feature type. In the parameters, set the tolerance to 1; this value is driven by the coordinate system of the features passing through the transformer.
5. Break Features in Points
Add a Chopper transformer to the canvas and connect it to the Generalizer. In the parameters, set the Maximum Vertices to 2.
6. Calculate the Length
Add a LengthCalculator to the canvas and connect it to the Chopper. Only the longest segment for each street will be used. We can use the LengthCalculator to determine this. Set the Length Dimension parameter to 2 (meaning 2D). The multiplier is set to 1 and will read the ground units, this number can be changed to scale the length to something different.
7. Sort Attributes
Add a Sorter transformer to the canvas and connect it to the LengthCalculator. This will sort the features by a selected attribute. In this case, we will set the attribute to _length as length has a unit we will use the Numeric option, and the order will be Descending. We will also have two more attributes to sort by, use, and name which will be sorted Alphabetically and in Ascending order.
8. Remove Duplicates
Add a DuplicateFilter to the canvas and connect it to the Sorter. This will divide the features based on selected attributes in this case by name and use. In the parameters, set the Key Attributes to name and use.
9. Filter Features by Length
Running the workspace up to this transformer will show that a lot of features pass through the duplicate port. To account for all the duplicates and add a Tester to test these duplicated features by the length of the feature. We want to include features that are greater than 300.
11. Label Streets
Add a Labeller to the canvas and connect it to both the DuplicateFilter Unique output port and the Tester Passed output port. Edit the following parameters to match the style in this article.
- Label: name
- Label Offset: 0
- Label Height: 28
- Label Spacing: 1000
The style you desire may require some experimentation.
12. Filter by Road Type
Add a TesterFilter to the canvas and connect it to the Labeller. The purpose of this TestFilter is to filter the type or use of each road in the dataset, in this case, ARTERIAL, COLLECTOR, and RESIDENTIAL. Set the following test conditions.
Test Condition |
Output Port |
|
---|---|---|
If |
@Value(use)=Secondary Arterial OR @Value(use)=Arterial |
ARTERIAL |
Else If |
@Value(use)=Collector |
COLLECTOR |
Else If |
@Value(use)=Residential |
RESIDENTIAL |
Else |
<All Other Conditions> |
<UNFILTERED> |
We will take a look at three different methods of setting Text Styles in a DGN file.
Method 1
Add an AttributeCreator to the canvas and connect it to the ARTERIAL output port on the TestFilter. We need to specify the attributes that are used to create text in Microstation.
New Attribute |
Attribute Value |
---|---|
igds_text_size |
48 |
igds_font |
1027 |
igds_justification |
7 |
igds_color |
3 |
Method 2
The DGNStyler provides a convenient interface to set a variety of Bentley Microstation Design format-specific attributes. Add a DGNStyler and connect it to the COLLECTOR output port on the TestFilter, Text Style attributes will be set using the Styler. Set the following attributes.
-
Color
- Color By Level: No
- Color Type: Index
- Index Number: 6
- Text
- Font Number: 1027
- Text Size: 38
Method 3
This method uses another DGNStyler also but different from Method 2 we are going to assign the Text Style ID. Add another DGNStyler to the canvas and connect it to the RESIDENTIAL output port on the TestFilter. In the DGNStyler_2 parameters set the following parameters
- Text Style ID: 3
13. Write out Street Names to DGN
Right-click on the canvas and choose Insert Writer Feature Type. Name the Feature Type StreetNames. Connect the AttributeCreator, DGNStyler_COLLECTOR and DGNStyler_RESIDENTAL to the Writer Feature Type.
14. Style DGN Park Polygons
Add a DGNStyler to the canvas and connect it to the ParkPolygons_small reader feature type.
Open the DGNStyler Parameters. Enable Color, then set Color Type to Color Index, set the Index Number to 82, and the Fill Index Number to 2.
By setting the Color Type to Color Index we must specify the color to use in the Index Number. The number used for Index and Fill Index is an assigned value between 0 and 255 in Microstation.
For more information on the DGNStyler please see this link.
15. Add DGN Writer Feature Type
Next, add a DGN Writer (V8) Feature Type and connect the DGNStyled output port to the DGN Writer. Specify the destination of the DGN file and ensure it has the same name (VancouverStreets) as the DGN file created in the DGN Writer that we created in the previous step.
16. Create Bounding Box around Park Polygons
Add a CenterPointReplacer, this will replace the geometry of a feature with a point that is either at the center of the features bounding box or at the center of mass of the feature. Connect the ParksPolygon_small reader feature type to this transformer. In the parameters, select Center Point of Bounding Box for the Mode.
17. Change Case of the NAME Attribute
Add a StringCaseChanger and connect it to the CenterPointReplacer, this changes the case of text attributes to uppercase, lowercase, Title case, or Full Title Case. Select NAME as the Attribute and choose Full Title Case as the Case Change.
18. Filter out Parks with no name.
To filter out any Parks that do not have a name, we need to use a Tester transformer. Add a Tester to the canvas and connect it to the StringCaseChanger. Set the Logic to NOT, the Left Value will be the NAME attribute, Operator will be Attribute is Missing meaning if there is no name the attribute will exit through the failed port.
For park polygons, labels are created by replacing polygon center points with texts using a LabelPointReplacer transformer. Once again, text style can be set by a DGNStyler transformer’s Text Style ID parameter.
19. Add a Point to Attach Labels
Add a LabelPointReplacer, connect the Passed port from the ParkNameTester to the LabelPointReplacer. This transformer will replace the geometry of the park polygons with a label point. Set the label parameter to read the NAME attribute, set the height to 40 and rotation to No.
20. Style DGN Text
Add a DGNStyler to the canvas and connect it to the LabelPointReplacer. The DGNStyler will require a little bit of experimentation to try and find the desired font. Open the Parameters and click the Color checkbox set Color By level to No and Color type to Color Index. Click the checkbox for Text and set the Text Style ID to 4.
Results
Vancouver Streets and Parks in Bentley MicroStation V8
How to find out igds_textstyle_id or igds_font values
To find out igds_textstyle_id and/or igds_font values:
- open your seed-file in MicroStation;
- add text features using text styles and/or fonts you are interested in;
- view the seed-file in Data Inspector and check igds_textstyle_id and/or igds_font values;
- delete the added text feature from the seed-file;
- save the seed-file.
It is recommended to do this using the seed-file rather than another file, as when a text style or a font is added to the seed-file it gets ‘introduced’ to the seed-file (gets igds_textstyle_id or igds_font value assigned from FME user point of view).
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.
Comments
0 comments
Please sign in to leave a comment.