Give Your DWG Some Style: Using the DWGStyler, Template Files, Blocks and More

Pierre  Koelich
Pierre Koelich
  • Updated

Introduction

There are several ways to style a DWG file with FME. The most common methods are implementing the DWGStyler transformer, setting the Layer Properties in the writer, or leveraging an existing template DWG file. This article touches on each method and includes a few examples for download so you can experiment for yourself.

Before we start, there are a few considerations to note when working with DWG files, particularly differences in how FME and AutoCAD represent styles. Namely, the FME Data Inspector is limited in how it displays lines. It can only display line color, but not line type, weight, etc. The FME Data Inspector will also not display area fill patterns (e.g., hatches). As with almost all DWG translations, it is therefore strongly recommended that you inspect your output data in AutoCAD. That being said, just because the FME Data Inspector does not display these details, the properties are still there. You can see AutoCAD-specific properties in the format attributes for a given feature (in the right-hand Feature Information window).

It is important to note that when a DWG file is written with one of the DWG writers, the writer looks for and uses AutoCAD-specific format attributes. These can be identified by the “autocad_” prefix.

For more information on how FME represents DWG features, check out this section of theFME documentation.

 

What is a Template DWG File?

Whenever you would like more control over the appearance and state of the various layers in your output DWG file, it is highly recommended that you leverage a template DWG file. A template is an existing DWG file containing the line styles, layer properties, blocks, etc., that you would like to be applied in your written product. This template can be used in two places: in the writer (click on Parameters, then find Template File and select your template file), and in the DWGStyler transformer. When using a template file in the DWGStyler, including the template in your writer is essential. This is discussed further below.

 

Setting Layer Properties

The default Layer Properties of a DWG file can be set in FME when writing out a DWG file. There are two simple ways to assign these:

  • By defining them in the Format Parameters in the output Feature Type.
  • By using a template file with Layer Properties already defined.

 

Examples

Example 1: Setting Layer Properties in the DWG Output Feature Type Without a Template File

If you do not have a template file with Layer Properties already defined, the simplest method of setting styles for a DWG is to adjust the Feature Type Properties in the output feature type. This is demonstrated in the first example workspace (example1.fmwt).

On the output, DWG Feature Type, open up the Feature Type Properties by double-clicking on the output feature type, then choose the Format Parameters tab with the green cog. Here you can set your AutoCAD layer properties. Layer Properties will only apply to features that do not already have a color assigned to them.

 

The output of example one, as seen in AutoCAD 2024. We get red, green, and blue road lines when the workspace is run. If we open the Layer Properties, we can verify where and how our settings have been applied.

 

Example 2: Setting Layer Properties in the DWG Output Feature Type With a Template File

If you already have a DWG file that contains layers with already-defined styles, such as the one in the template.dwg, then FME lets you leverage these properties by using it as a template file.

To add a template file to a DWG writer, find the template file parameter in the Navigator pane on the left. For a template file to work correctly, you will need to ensure that the layer names in your template DWG file match the output layer names in your workspace.

This is demonstrated in example2.fmwt 

Example 2 looks identical on the surface to example 1; however, our ACAD writer now has a template DWG file defined. The template DWG file already has the predefined layers Roads-Arterial and Roads-Residential. We no longer need to set the layer properties for each outgoing feature type manually. 

Notice, though, that our template does not define Roads-Other. Roads-Other will work just as it did in example one. Open the Format Parameters in Roads-Other to see what Layer Properties we can expect.

 

When you use a template while writing a DWG, the writer will ignore any Layer Properties you have manually set if the feature type name matches a layer name in the template file.

 

The output of example two, as seen in AutoCAD 2024. When the workspace is run, we get red, green, and blue road lines, just as in example one. If we open the Layer Properties, we can verify that the Layer Properties from our template file have been applied.

 

The DWGStyler Transformer

If you want more control over your default layer properties, applying a template DWG to the writer is one of the best ways to achieve your desired output. The DWGStyler's role, however, is to provide an opportunity to make some additional alterations to the properties at a feature level instead of a layer level (or feature type level).

The DWGStyler lets you modify the appearance of blocks, texts, lines, and various area features of your data set. If you use AutoCAD, the parameters in the DWGStyler should look somewhat familiar. Not all DWGStyler parameters are covered in this article; if you want to learn more, check out the DWGStyler documentation.

As with the DWG file writers, the DWGStyler lets you leverage an existing template file. However, when you apply a template to the DWGStyler, this will not affect the output. Instead, it allows you to access block libraries, line styles, or other custom attributes defined within the template. This is very useful when you want to create or modify blocks from an original template library or change the appearance of certain layers to better suit your output DWG (e.g., block rotation and scale, line styles, or custom fill patterns).

 

Below are two examples that use the DWGStyler. The first one (example3.fmwt) uses the transformer to give fonts and colors to text labels, the second example (example4.fmwt) uses a template file to turn point features into predefined blocks.

 

Example 3: Using the DWGStyler Without a Template File

As mentioned above, using the DWGStyler will assign styles to your dataset at a feature level. We can style different features and save them all as one layer. The DWGStyler can also style multiple geometries simultaneously, so there’s no need to separate out geometries.

In example three, we have used the DWGStyler to color different “RoadTypes” from a geodatabase. At the same time, some text features, which are created in the workspace by a labeller, are also getting styled. Once the features have been styled, they are merged into a single layer in our DWG output. Our output DWG will contain labelled roads with different styles, all in a single layer.

 

Example 4: Using the DWGStyler to Create Blocks With a Template File

While FME can create AutoCAD blocks, using predefined blocks from a template file is much easier and quicker. When you apply a template file to the DWGStyler, it does not affect the output as shown in the previous examples. Instead, it allows you to access the block libraries, line styles, and other custom formats within the template. This is very helpful when you want to create predefined blocks from point features or change the appearance of certain features to align with any custom styles.

Download and examine example4.fmwt. In this example, with the help of the DWGStyler, we quickly convert our point features from a geodatabase into blocks already predefined in our template file. Thanks to the DWGStyler, StreetLights and TrafficSignals are each given their own respective block definitions and are then merged into a single layer called Lights. If we open up our output in AutoCAD, we can see that what was once boring old points are now funky blocks!

If you are using a template file in a DWGStyler to define blocks, you will need to include the same template file in your DWG writer. After features pass through the DWGStyler, they are still represented in FME as point features; however, the features will now have additional format attributes, including autocad_block_name. The template file will look for a match when the writer encounters these attributes. If no template exists in the writer, then by default, these features are rejected and will not be written.

In this example, we use the DWGStyler with a template file to assign our input points with some funky blocks. In the example, some simple labels have been created from an applicable attribute with the help of the LabelPointReplacer and the Offsetter. The labels and point features are all written in the same layer as our output DWG. Upon writing, the points are converted to the respective blocks with the help of the template file in the writer. You may notice that the labels did not pass through a DWGStyler; they will adopt the default Layer Properties, which were set using the method outlined in Example 1 above.

 

If you open the DWGstyler Blocks parameters with the Blocks box checked and a template file in use, as shown here, we can click on the highlighted ellipses to access any blocks defined in the template. In this case, we have two blocks: ‘Light’ and ‘Signal’. Here, we could have also chosen to scale or rotate the blocks.

 

Here is a zoomed-in view of the output of example four as viewed in AutoCAD 2024. In this view, we can see labelled Light blocks surrounding a Signal block.

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.