DWG Reader
| AutoCAD | ||
| File Extension | AutoCAD - 2D | AutoCAD - 3D |
| File Extension | DWG, DXF | DWG, DXF |
| Supported Versions | Up to AutoCAD 2025 | Up to AutoCAD 2025 |
| Platforms | ||
| Tessellation | Supported | Supported |
| B-rep | N/A | Supported |
| PMI | Supported | N/A |
AutoCAD is a digital file format used to create, store, and edit both 2D and 3D designs. An AutoCAD file (DWG) can store either 2D drawings, which show objects in length and width, or 3D models, which also include depth to represent fully three-dimensional shapes.
Both 2D and 3D may be present in the same file.
Please note that our DWG reader is currently only available on Windows and Linux, with the exception of support on Android for 2D data.
A file does not need to have a particular extension to be read correctly by HOOPS Exchange. However, the file extensions of DWG files that you can expect to be loaded by HOOPS Exchange include:
- .DWG
- .DXF
How to Import from AutoCAD
Reading AutoCAD files follows the same pattern as other formats: configure load parameters, then call the standard load function.
To load an AutoCAD (either 2D or 3D) file, use A3DAsmModelFileLoadFromFile().
The A3DParamsLoadData structure is used to customize the loading behavior:
A3DAsmModelFile* pModelFile = 0;
A3DRWParamsLoadData sReadParam;
A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sReadParam);
sReadParam.m_sGeneral.m_bReadSolids = true;
// ... set other A3DRWParamsLoadData fields as necessary
A3DAsmModelFileLoadFromFile("path/to/file.dwg", &sReadParam, &pModelFile);
See Simple Load and Export for more about loading model files.
If you need more detail about the load parameters, see import_params_reference. For guidance on working with tessellation, consult extracting_tessellation.
Drawings – 2D
2D drawings are made up of one or more sheets. Each sheet may contain blocks, tables, text, dimensions, images, OLE objects (such as Excel spreadsheets), filled areas, and various wireframe elements including lines, arcs, and polylines.
A block is a subsection of a sheet and can itself include any of these elements.
Every item can be assigned to a layer and defined by properties such as line type, color, and line width.
Filled areas can be rendered using hatch patterns or solid colors.
Units
For 3D models, units are defined by the INSUNITS variable.
There is a specific treatment for the DXF file extension.
MEASUREMENT variable is used if it is defined and if INSUNITS is not defined.
In this case if MEASUREMENT is set to English (0), the unit will be set as kA3DUnitInch – if MEASUREMENT is set to metric (1), the unit will be set as kA3DUnitMillimeter.
Attributes
Limitation: Exchange does not currently support document attributes (Author, Title, etc.).
Sheets
Sheets are supported.
DWG files can contain several sheets.
Each sheet is saved in A3DDrawingModelData.m_ppDrwSheets.
Sheets contain drawing blocks, views, and wireframes.
Wireframes are converted into polylines.
Limitation: Exchange does not support sheet sets.
Drawing Views
A drawing can be created in two environments: model space and paper space, which are accessed through the Model and Layout tabs.
Model space is the three-dimensional workspace where a model composed of geometric objects is created. Model space supports single-view drawings.
The final presentation of this model – consisting of selected views, scales, and annotations – is then arranged in paper space, a two-dimensional workspace. Once the model is complete, it is prepared for plotting in the Layout tab within paper space. Paper space supports multiple-view drawing layouts of the model.
Both single-view drawings and multiple view drawing layouts are supported by HOOPS Exchange.
Blocks
Each sheet may contain blocks, tables, text, dimensions, images, OLE objects (such as Excel spreadsheets), filled areas, and various wireframe elements including lines, arcs, and polylines. However, please note that OLE objects are not supported.
A block is a subsection of a sheet and can itself include any of these elements.
Every item can be assigned to a layer and defined by properties such as line type, color, and line width.
Filled areas can be rendered using hatch patterns or solid colors.
Limitation: Exchange does not support block attributes or block behaviors.
Layers
Layers are used to group data and change graphical attributes.
This includes:
- Colors
- Line Type
- Line Weight
- Transparency
All of these attributes are supported by HOOPS Exchange.
Layers have names and properties.
Limitation: Exchange does not support Layer properties.
Geometry
Geometry support includes lines, polylines, arcs, circles, tori, ellipses, splines, helices, and construction/reference geometry.
Limitations: All entities are converted to polylines. Geometry constraints are not supported.
Annotations
Hatches, fills, wipeouts, notes and labels, tables, dimensions and tolerance are all displayed.
3D Models
Polysolids, B-rep, and meshes are supported.
Exchange also supports trimmed/untrimmed surfaces, NURBS, and procedural surfaces.
Miscellaneous
Sections in 2D drawings are tessellated.
For materials, Exchange supports transparency and specular, ambient and diffuse color.
Xrefs are supported; If a DWG file has references to external DWG files, they will be loaded.
The following entities are not supported:
- Lighting
- Textures
- Password-protected files and encrypted files
- Embedded Data (OLE)