Default database converter for DXF files.

This class extends AcDbDatabaseConverter to provide specialized functionality for converting DXF (Drawing Exchange Format) files into AcDbDatabase objects. It handles parsing DXF data, processing entities, blocks, tables, and other DXF-specific structures.

const converter = new AcDbDxfConverter();
const database = await converter.convert(dxfData);

Hierarchy (View Summary)

Constructors

Properties

Optional progress callback for tracking conversion progress

Methods

  • Gets all fonts used by entities in model space and paper space.

    This method analyzes the DXF data to extract all font names used by text entities, MText entities, and insert entities throughout the drawing.

    Parameters

    • dxf: ParsedDxf

      Input parsed DXF model

    Returns string[]

    Array of font names used in the drawing

    const fonts = converter.getFonts(parsedDxf);
    console.log('Used fonts:', fonts);
  • Processes dimension style table records from the DXF file.

    This method creates AcDbDimStyleTableRecord objects for each dimension style defined in the DXF tables section, including all dimension-related properties like text positioning, arrow settings, and tolerance settings.

    Parameters

    • model: ParsedDxf

      Parsed DXF model containing dimension style definitions

    • db: AcDbDatabase

      Target database to add dimension style table records to

    Returns void

    converter.processDimStyles(parsedDxf, database);
    
  • Processes entities in batches to maintain UI responsiveness.

    This method breaks up the entity processing work into smaller chunks that are executed asynchronously. This is often referred to as "batch processing" or "cooperative multitasking," where the time-consuming task is broken into smaller pieces and executed in small intervals to allow the UI to remain responsive.

    Parameters

    • dxf: ParsedDxf

      Parsed DXF data

    • db: AcDbDatabase

      Target database to add entities to

    • minimumChunkSize: number

      Minimum number of entities to process in each chunk

    • startPercentage: { value: number }

      Object containing the starting percentage for progress tracking

    • Optionalprogress: AcDbConversionProgressCallback

      Optional callback for progress updates

    Returns Promise<void>

    await converter.processEntities(dxf, database, 100, { value: 0 }, progressCallback);
    
  • Processes header variables from the DXF file.

    This method extracts and sets various header variables such as color settings, angle base, angle direction, units, and point display settings.

    Parameters

    • model: ParsedDxf

      Parsed DXF model containing header information

    • db: AcDbDatabase

      Target database to set header variables on

    Returns void

    converter.processHeader(parsedDxf, database);
    
  • Processes layer table records from the DXF file.

    This method creates AcDbLayerTableRecord objects for each layer defined in the DXF tables section, including their properties like color, linetype, lineweight, and visibility settings.

    Parameters

    • model: ParsedDxf

      Parsed DXF model containing layer definitions

    • db: AcDbDatabase

      Target database to add layer table records to

    Returns void

    converter.processLayers(parsedDxf, database);
    
  • Processes viewport table records from the DXF file.

    This method creates AcDbViewportTableRecord objects for each viewport defined in the DXF tables section, including their properties like center, corners, snap settings, and grid settings.

    Parameters

    • model: ParsedDxf

      Parsed DXF model containing viewport definitions

    • db: AcDbDatabase

      Target database to add viewport table records to

    Returns void

    converter.processViewports(parsedDxf, database);
    
  • Reads and converts data into an AcDbDatabase.

    This method orchestrates the entire conversion process, including parsing, processing various components (fonts, linetypes, styles, etc.), and building the final database.

    Parameters

    • data: string | ArrayBuffer

      The input data to convert (string or ArrayBuffer)

    • db: AcDbDatabase

      The database to populate with converted data

    • minimumChunkSize: number

      Minimum chunk size for batch processing

    • Optionalprogress: AcDbConversionProgressCallback

      Optional progress callback

    Returns Promise<void>

    Promise that resolves when conversion is complete

    const converter = new MyConverter();
    const database = new AcDbDatabase();
    await converter.read(dxfData, database, 100, progressCallback);