AutoCAD RealDWG is a software development toolkit (SDK) provided by Autodesk that allows developers to read, write, and create DWG and DXF files (AutoCAD’s native drawing file formats) without needing AutoCAD installed.
The target of this project is to create one web-version of AutoCAD RealDWG by providing the similar API. For now, it supports reading DWG and DXF file only. In the future, it will support write DWG and DXF too.
You can access its API doc here.
To support reading both DXF and DWG files (and potentially other formats in the future), this project provides a flexible mechanism for registering and unregistering file converters. This is managed by the AcDbDatabaseConverterManager
class.
AcDbDatabaseConverterManager
maintains a registry of these converters, allowing you to register or unregister converters for specific file types at runtime.To register a converter for a file type:
import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter';
// WASM module loading (async)
import('@mlightcad/libredwg-web/wasm/libredwg-web').then(libredwgModule => {
const dwgConverter = new AcDbLibreDwgConverter(libredwgModule);
AcDbDatabaseConverterManager.instance.register(AcDbFileType.DWG, dwgConverter);
});
To unregister a converter for a file type:
import { AcDbDatabaseConverterManager, AcDbFileType } from '@mlightcad/data-model';
// Unregister the DWG converter
AcDbDatabaseConverterManager.instance.unregister(AcDbFileType.DWG);
To get the converter for a specific file type:
const converter = AcDbDatabaseConverterManager.instance.get(AcDbFileType.DXF);
This mechanism allows you to:
This design ensures the system is open for extension and can easily adapt to new requirements or file formats in the future.
AutoCAD holds an absolute dominant position in the 2D CAD field. A large number of vertical applications and third-party plugins have been developed based on AutoCAD ObjectARX, and there are many software engineers familiar with AutoCAD ObjectARX. Therefore, this project mimics the architecture of AutoCAD ObjectARX and adopts similar API interfaces to AutoCAD ObjectARX.
This module provides a DWG file converter for the RealDWG-Web ecosystem, enabling reading and conversion of DWG files into the drawing database. It is powered by the libdxfrw library compiled to WebAssembly and is designed to be registered with the converter manager for DWG file support.
This module provides a DWG file converter for the RealDWG-Web ecosystem, enabling reading and conversion of DWG files into the drawing database. It is powered by the LibreDWG library compiled to WebAssembly and is designed to be registered with the converter manager for DWG file support.
This module provides geometric entities, operations, and transformations. It consists of two kinds of classes.
The key classes in this module are as follows.
The same drawing database structure is used in this project so that it is easier for AutoCAD ObjectARX developers to develop their own application based on SDK of this project. Please refer to AutoCAD Database Overview to get more information on AutoCAD drawing database structure.
This module contains the core classes for interacting with AutoCAD's database and entities (e.g., lines, circles, blocks, etc.).
The key classes in this module are as follows.
Please refer to AcDb classes in AutoCAD ObjectARX Reference Guide to get more details on those classes.
The differnt API interfaces from AutoCAD ObjectARX are used in this module because of the following reasons.
This module provides the graphics interface to control how AutoCAD entities are displayed on the screen.
The key classes in this module are as follows.