Basic DWG Block Handling Example: Preserving Block Entities (DWG to SHP)

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

In this tutorial, we will translate a DWG file representing traffic signals to an Esri shapefile (.shp). The signals are stored as blocks in the DWG file, and there is a text entity that holds the signal ID. Our goal is to:

  • Translate the block insertion point into a single point in our output shapefile, and
  • Move the signal ID into an attribute of the point.

This transformation highlights one way to work with AutoCAD block entities in FME: not exploding blocks (preserving their insertion points) works well when translating to a format that does not store such complex entities or require single geometries in the output.

Source Data

The image below shows an example of one of the traffic signals in this DWG file, which is stored as a block.

In addition to this block, there is a text label indicating an ID for the signal. This is not contained within the block, but rather it is stored on the TrafficSignals layer along with our block.

imageedit-1-9299526017.png


Let’s see how FME handles this data by looking at the DWG file in the FME Data Inspector, with the reader parameter Explode Blocks into Entities unchecked:


FME has read the 'insert point' of the blocks, which represents the block's location (in blue). Note that the red point represents the text insertion point, which is different. The blue insert point will be translated into the shapefile. The text representing the signal IDs is also stored on the TrafficSignals layer and is moved onto the insert point using a NeighborFinder transformer.
 

Step-by-Step Instructions

1. Start FME Workbench and add an AutoCAD DWG/DXF Reader to a blank workspace.

In the Add Reader dialog, select AutoCAD DWG/DXF for the Format, and the trafficsignals.dwg file for the Dataset.

Click on the Parameters button.

Ensure ‘Group Entities By’ is set to ‘Layer Name’.

We want to keep the block preserved as one single entity (point), so do not explode the blocks in the reader parameters:

Click OK twice.

We only need the TrafficSignals feature type, so deselect the ‘0’ feature type in the Select Feature Types dialog.

2. Expose autocad_text_string

Open the TrafficSignals reader feature type parameters. Click on the Format Attributes tab. Use the search feature to find and check autocad_text_string. Click OK. We will work with this attribute later.

3. Add GeometryFilter

Add a GeometryFilter transformer to the workspace. In the parameters, click the ellipsis next to Output Ports to select the geometry types to filter.

Separate the points (block insertion points) from the text (which represents Signal IDs) by selecting ‘Points’ and ‘Text’. Click on OK, and OK again. This prepares the data for the NeighborFinder.

4. Add NeighborFinder

Connect the Point output port from the GeometryFilter to the NeighborFinder's Base input port. Connect the Text output port to the Candidate port.

Open the NeighborFinder parameters,  set the Maximum Distance to 5 (use the Measure tool in the Data Inspector to confirm this is a good number to use). Click Apply.

5. Add AttributeRenamer

Connect the MatchedBase port to an AttributeRenamer transformer. Rename autocad_text_string to SignalID.

6. Add an Esri Shapefile Writer

From the Writers menu, select Add Writer.

Add an Esri Shapefile writer. Select a location for the dataset. Set the Shapefile Definition to Manual. Click OK.

In the Feature Type dialog, set the Shapefile Name to trafficsignals. 

7. Connect the Writer Feature Type

Connect the trafficsignals writer feature type to the AttributeRenamer. Open the Feature Type parameters,  select the ‘User Attributes’ tab. Remove all attributes except the one you created in the AttributeRenamer (SignalID). Click Apply.

Run the workspace and inspect the output. In the attribute table, you will now see single points with the text label as an attribute.

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?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.