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

  • get database(): AcDbDatabase

    Gets the database object containing all drawing data.

    Returns AcDbDatabase

    The underlying CAD database instance

  • get docTitle(): string

    Gets the display title of the document.

    Returns string

    The document title displayed in the window/tab

  • set docTitle(value: string): void

    Sets the display title of the document.

    Also updates the browser tab title if running in a browser environment.

    Parameters

    • value: string

      The new document title

    Returns void

  • get isReadOnly(): boolean

    Gets whether the document is opened in read-only mode.

    Returns boolean

    True if the document is read-only, false if editable

  • get uri(): undefined | string

    Gets the URI of the document if opened from a URI.

    Returns undefined | string

    The document URI, or undefined if not opened from URI

Methods

  • Opens a CAD document from file content.

    Parameters

    • fileName: string

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

    • content: string | 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
    });