Autodesk AutoCAD DWG/DXF Reader/Writer
This format contains Autodesk® RealDWG by Autodesk, Inc.1Copyright © 1998-2006 Autodesk, Inc. All rights reserved.
This chapter is about the AutoCAD DWG/DXF reader/writer and AutoCAD feature types supported by FME. For AutoCAD DWF information, please refer to the Autodesk AutoCAD DWF Reader/Writer.
FME can read and write files used by Autodesk® AutoCAD® and compatible systems. AutoCAD drawing files consist of drawing settings and configuration, as well as a series of entities, or graphic elements, organized into layers.
FME provides broad support for many AutoCAD entity types and options, and for reading and writing AutoCAD file versions up to and including 2013, produced by AutoCAD applications of version 2013 or newer.
When AutoCAD data is output, header information may be copied from a supplied template, or prototype, file.
The AutoCAD reader first reads the header and table information from the drawing file being processed, and caches information on blocks, shape files, layers, linetypes, and applications. These cached values are referenced by entities throughout the file and are needed when processing the entities.
The reader then extracts entities, one at a time, from the entity section of the drawing file and passes them on to the rest of FME for processing. Complex entities such as polylines and inserts are extracted as single FME features. If the entity has attribution stored as extended entity data, then this is also read and placed in the feature.
When the AutoCAD reader encounters an entity type it does not know how to process, it simply sets the entity type of the feature and returns it. This feature is then logged by the FME correlation subsystem and the reader moves on to the next entity.
The AutoCAD reader consists of Source Autodesk AutoCAD DWG/DXF File(s).
The AutoCAD writer provides the following capabilities when writing AutoCAD files.
- User-defined Linetypes: New linetypes can be defined on FME mapping file lines. These linetypes can then be referenced by features being written to the AutoCAD file.
- User-defined Layers: Users must define the layers into which features are stored. The layers can also define the attributes to be stored within the feature.
- Copy Block Definitions: Often users have existing AutoCAD drawing files that contain block definitions they want the translated data to carry. Specifying the Template File parameter results in block definitions being copied from the existing file to the output DWG/DXF file. These blocks can then be referred to by insert entities.
- Copy Linetypes: Predefined linetypes within existing DWG/DXF files are copied making them available for use by features being written to the destination file. Specifying the Template File parameter in the mapping file results in the predefined linetypes being copied from the template file to the output drawing file. Feature entities can then refer to these linetype definitions.
- Copy Layer Definitions: Layer definitions within an existing DWG/DXF file identified by Template File parameter enable layer definitions to be copied to the destination data set and then referenced.
- Copy Shape Header Definitions: Shape header definitions are also copied from the file specified by the Template File parameter.
- Automatic Block Creation: When a feature is passed to the writer that cannot be written as a single AutoCAD entity, such as a donut polygon, the writer automatically defines an AutoCAD block and inserts entities necessary to represent the feature. If a block is already defined with that name, either through previous block creation or through existence in the template file, then the existing block definition will be used and the multi-part feature will be added at an insert point calculated from the feature geometry. If the autocad_block_insert_[xyz] attributes are specified, they will be used to specify an insert point for the new block reference.
- Multi-version support: The AutoCAD DWG/DXF writer supports files that are compatible with any current AutoCAD release.
- Flexible Attribute Support: Attribute information can be written through the use of the autocad_attributes attribute being set as shown in the following table.
This results in the attribution being written to the extended entity for the feature.
This results in the writer creating an insert entity for each feature and storing all attributes with the insert entity. The insert entity refers to a block that contains the geometry of the output feature.
This is the default value. Limited attributes are written to the AutoCAD file. This is useful if the attributes are being stored in an external database. Note that list formatted extended entity data as created by the AutoCAD Reader may still be written.
When creating AutoCAD files, the AutoCAD writer first defines the linetypes and layers defined within the FME mapping file. The writer then reads in a template file, if specified, and copies the linetypes, layer definitions, shape file header information, and block information from the template file to the output dataset.
The AutoCAD writer then outputs each feature it is given to the output file in the appropriate entity type.
When writing an AutoCAD file, the format of file output is determined as follows:
- If the file name contains .dwg or .DWG, then the output data set is written in the ACAD format.
- Otherwise, if the file name contains .dxf or .DXF, then the output data set is written in DXF format.
- Otherwise, if an error exists in the mapping file, the translation is halted.
- XRecord data Support: Currently the AutoCAD DWG/DXF writer supports the creation of XRecord writing to the extension dictionaries of written entities.
The AutoCAD writer uses the above rules to enable the same underlying FME mapping file to be used to create both DXF and DWG output files. Users are able to specify their choice simply by changing the suffix of the output file being produced.