Manager for registering and managing database converters by file type.

This class provides a centralized way to register database converters for different file types (DXF, DWG, etc.) and retrieve the appropriate converter for a given file type. It implements the singleton pattern and provides event notifications when converters are registered or unregistered.

The manager registers a native DXF converter (AcDbNativeDxfConverter) for AcDbFileType.DXF by default as soon as the singleton is created, so DXF files can be read without any explicit registration. Calling register again for the same file type replaces the previous converter (e.g. with @mlightcad/dxf-json-converter).

const manager = AcDbDatabaseConverterManager.instance;
const converter = manager.get(AcDbFileType.DXF);
if (converter) {
await converter.read(dxfData, database, { minimumChunkSize: 100 });
}

Properties

Events that can be triggered by the converter manager.

These events allow applications to respond to converter registration and unregistration.

Type declaration

Accessors

  • get fileTypes(): IterableIterator<string>
  • Gets all registered file types.

    Returns IterableIterator<string>

    An iterator of all registered file types

    const fileTypes = manager.fileTypes;
    for (const fileType of fileTypes) {
    console.log('Supported file type:', fileType);
    }

Methods

  • Gets the database converter associated with the specified file type.

    Parameters

    • fileType: string

      The file type to get the converter for

    Returns undefined | AcDbDatabaseConverter<unknown>

    The database converter associated with the specified file type, or undefined if not found

    const converter = manager.get(AcDbFileType.DXF);
    if (converter) {
    await converter.read(dxfData, database, { minimumChunkSize: 100 });
    }