Manages layout objects in a drawing database.

This class provides functionality for managing layouts, including creating, finding, renaming, and switching between layouts. It also provides event notifications when layouts are switched.

const layoutManager = new AcDbLayoutManager();
const layoutCount = layoutManager.countLayouts();
const activeLayout = layoutManager.findActiveLayout();

Constructors

Properties

events: { layoutSwitched: AcCmEventManager<AcDbLayoutEventArgs> } = ...

Events that can be triggered by the layout manager.

These events allow applications to respond to layout changes.

Type declaration

Methods

  • Gets the number of layouts in the layout dictionary.

    This includes the Model tab, which is always present.

    Parameters

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns number

    The number of layouts in the dictionary

    const count = layoutManager.countLayouts();
    console.log(`Number of layouts: ${count}`);
  • Gets the name of the active layout in the database.

    Returns string

    The name of the active layout, or 'Model' if no layout is active

    const activeLayoutName = layoutManager.findActiveLayout();
    console.log('Active layout:', activeLayoutName);
  • Finds a layout by name in the database.

    Parameters

    • name: string

      Name of the layout to find

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns undefined | AcDbLayout

    The layout object, or undefined if not found

    const layout = layoutManager.findLayoutNamed('A4 Landscape');
    if (layout) {
    console.log('Found layout:', layout.layoutName);
    }
  • Return true if the layout named 'name' is found in the database 'db' (or the workingDatabase if 'db' isn't provided).

    Parameters

    • name: string

      Input name of layout to find.

    • Optionaldb: AcDbDatabase

      Input drawing database to use. Default is the current database.

    Returns boolean

    Return true if the layout named name is found in the database 'db' (or the workingDatabase if 'db' isn't provided).

  • Renames a layout in the database.

    Parameters

    • oldName: string

      Current name of the layout to rename

    • newName: string

      New name for the layout

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns boolean

    True if the layout was renamed successfully, false otherwise

    const success = layoutManager.renameLayout('Old Name', 'New Name');
    
  • Sets the layout named 'name' as the current layout in the database.

    Parameters

    • name: string

      Name of the layout to make current

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns boolean

    True if setting the current layout was successful, false otherwise

    const success = layoutManager.setCurrentLayout('A4 Landscape');
    
  • Makes the layout object associated with the given block table record ID the current layout.

    Parameters

    • id: string

      Block table record ID for the layout object to make current

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns boolean

    True if setting the current layout was successful, false otherwise

    const success = layoutManager.setCurrentLayoutBtrId('some-block-id');
    
  • Makes the layout object associated with the given object ID the current layout.

    Parameters

    • id: string

      Object ID for the layout object to make current

    • Optionaldb: AcDbDatabase

      Drawing database to use (defaults to the current database)

    Returns boolean

    True if setting the current layout was successful, false otherwise

    const success = layoutManager.setCurrentLayoutId('some-layout-id');
    if (success) {
    console.log('Layout switched successfully');
    }