Represents a CAD document that manages a drawing database and associated metadata.

This class handles:

  • Opening CAD files from URIs or file content (DWG/DXF formats)
  • Managing document properties (title, read-only state)
  • Providing access to the underlying database
  • Handling file loading errors through event emission

Constructors

Accessors

Methods

  • Opens a CAD document from file content.

    Parameters

    • fileName: string

      The name of the file (used to determine file type from extension)

    • content: ArrayBuffer

      The file content as string or ArrayBuffer

    • options: AcDbOpenDatabaseOptions

      Options for opening the database, including read-only mode

    Returns Promise<boolean>

    Promise resolving to true if successful, false if failed

    const fileContent = await fetch('drawing.dwg').then(r => r.arrayBuffer());
    const success = await document.openDocument('drawing.dwg', fileContent, {
    readOnly: false
    });
  • Opens a CAD document from a URI.

    Parameters

    • uri: string

      The URI of the CAD file to open

    • options: AcDbOpenDatabaseOptions

      Options for opening the database, including read-only mode

    Returns Promise<boolean>

    Promise resolving to true if successful, false if failed

    const success = await document.openUri('https://example.com/drawing.dwg', {
    readOnly: true
    });