FME Version
Introduction
The goal of this exercise is to demonstrate how to work with exploded blocks in FME. Specifically, we will look at translating a DWG file into a PDF.
Source Data
In the image below, we see a DWG file containing two blocks with text saved in a separate layer. In this example, we will only be looking at one block to serve as a simple case demonstrating how to write blocks to a PDF.
Next to the wheel blocks are text labels indicating the wheel's ID. This information is not contained within the block but stored on the BicycleParts layer.
Step-by-Step Instructions
1. Open FME Workbench. Start with a blank workspace.
In Windows, this is found under Start > All Programs > FME Desktop > FME Workbench. To create a new blank workspace, click New under the Start tab (or press Ctrl + N) and select Blank Workspace.
2. Add AutoCAD DWG/DXF reader.
From the Readers menu, select Add Reader. Select Autodesk AutoCAD DWG/DWG as the Format, then browse to BlockTemplate.dwg as the Dataset. Then, click the Parameters button:
In the Parameters dialog, ensure that Group Entities By is set to ‘Layer Name’ and the ‘Explode Blocks into Entities’ option is enabled. This will explode the block into its constituent features (in this case, ellipses and polygons) so it will be displayed in the PDF just like it is in AutoCAD.
Click OK, then OK again.
3. Select Feature Types
When prompted to select layers to read, you will only need to select the layer that contains the blocks and the layer that contains the text you are interested in. The layer containing the block we want is on a layer named ‘BicycleParts’, and the layer containing the text we want is named 'WheelID'. Only select these layers to be added to the canvas.
4. Expose format attributes
Once the reader is added to the canvas, the next step is to extract the block we are interested in. To do this, we first need to expose two format attributes.
Click the BicycleParts reader feature type to open its properties in the Feature Type dialog. Click on the Format Attributes tab. Use the search feature to find and select autocad_block_name. Click OK.
Next, open the WheelID reader feature type parameters. Click on the Format Attributes tab. Use the search feature again to find and check autocad_layer. Click OK
5. Add Tester
Add a Tester to extract only the block we want from BicycleParts and the text, which is contained in a separate layer (WheelID). Connect both of the reader feature types to the Tester.
After examining the data in AutoCAD or the FME Data Inspector, we know that our block name is WheelBlock. Within the Tester transformer parameters, we want to test if the format attribute autocad_block_name = WheelBlock or if autocad_layer = WheelID.
6. Add Writer
From the Writers menu, select Add Writer.
Add a writer to your canvas in the Adobe Geospatial PDF format (PDF2D). Set the Dataset to wheels.pdf. Set the Layer Definition to Automatic. Click on Parameters.
Ensure that Scale Text Font is checked. Click OK and OK.
Set the Layer Name to wheels. Click OK
7. Run Workspace
Connect the ‘Passed’ port from the Tester to the writer. Run the workspace and inspect the results. You will find a PDF in the output directory you chose in step 6 that shows the block of interest:
Of course, you could use the DWGStyler transformer to modify the color of the block as well!
Comments
0 comments
Please sign in to leave a comment.