Block table record that serves as a container for entities within drawing databases.

Block table records (BTRs) are used to organize and group entities together. There are two special BTRs that are always present in every database:

  • *Model_Space: Contains entities in model space
  • *Paper_Space: Contains entities in paper space

Each block table record has an origin point and can contain multiple entities.

const blockRecord = new AcDbBlockTableRecord();
blockRecord.name = 'MyBlock';
blockRecord.origin = new AcGePoint3d(0, 0, 0);
blockRecord.appendEntity(new AcDbLine());

Hierarchy (View Summary)

Constructors

Properties

MODEL_SPACE_NAME: string = '*Model_Space'

Name constant for model space block table record

PAPER_SPACE_NAME_PREFIX: string = '*Paper_Space'

Name prefix for paper space block table records

Accessors

  • get database(): AcDbDatabase
  • Gets the database in which this object is resident.

    When an object isn't added to a database, this property returns the current working database. After it is added to a database, it will be set automatically. You should never set this value manually.

    Returns AcDbDatabase

    The database this object belongs to

    const db = obj.database;
    
  • set database(db: AcDbDatabase): void
  • Sets the database for this object.

    This is typically set automatically when the object is added to a database. Manual setting should be avoided unless you know what you're doing.

    Parameters

    Returns void

    obj.database = myDatabase;
    
  • get isModelSapce(): boolean
  • Returns true if this is a model space block table record.

    Model space is the primary drawing area where most entities are created.

    Returns boolean

    True if this is a model space block table record

    if (blockRecord.isModelSapce) {
    console.log('This is model space');
    }
  • get isPaperSapce(): boolean
  • Returns true if this is a paper space block table record.

    Paper space is used for creating layouts for printing and plotting.

    Returns boolean

    True if this is a paper space block table record

    if (blockRecord.isPaperSapce) {
    console.log('This is paper space');
    }
  • get name(): string
  • Gets or sets the name of the symbol table record.

    This property corresponds to DXF group code 2 and is used for identifying and referencing the symbol table record.

    Returns string

    The name of the symbol table record

    const recordName = record.name;
    record.name = 'NewRecordName';
  • set name(value: string): void
  • Parameters

    • value: string

    Returns void

  • get objectId(): string
  • Gets the object ID.

    AutoCAD uses 64-bit integers to represent handles, which exceed the maximum integer value of JavaScript. Therefore, strings are used to represent object handles.

    Returns string

    The object ID as a string

    const id = obj.objectId;
    console.log(`Object ID: ${id}`);
  • set objectId(value: string): void
  • Sets the object ID.

    Parameters

    • value: string

      The new object ID

    Returns void

    obj.objectId = 'new-object-id';
    
  • get ownerId(): string
  • Gets the object ID of the owner of this object.

    Returns string

    The owner object ID

    const ownerId = obj.ownerId;
    
  • set ownerId(value: string): void
  • Sets the object ID of the owner of this object.

    Parameters

    • value: string

      The new owner object ID

    Returns void

    obj.ownerId = 'parent-object-id';
    

Methods

  • Appends the specified entity to this block table record.

    This method adds an entity to the block and sets up the necessary relationships between the entity and the block table record.

    Parameters

    • entity: AcDbEntity

      The entity to append to this block table record

    Returns void

    const line = new AcDbLine();
    blockRecord.appendEntity(line);
  • Closes the object.

    All changes made to the object since it was opened are committed to the database, and a "closed" notification is sent. This method can be overridden by subclasses to provide specific cleanup behavior.

    Returns void

    obj.close();
    
  • Gets the value of the specified attribute.

    This method will throw an exception if the specified attribute doesn't exist. Use getAttrWithoutException() if you want to handle missing attributes gracefully.

    Parameters

    • attrName: string

      The name of the attribute to retrieve

    Returns any

    The value of the specified attribute

    When the specified attribute doesn't exist

    try {
    const value = obj.getAttr('objectId');
    } catch (error) {
    console.error('Attribute not found');
    }
  • Gets the value of the specified attribute without throwing an exception.

    This method returns undefined if the specified attribute doesn't exist, making it safer for optional attributes.

    Parameters

    • attrName: string

      The name of the attribute to retrieve

    Returns any

    The value of the specified attribute, or undefined if it doesn't exist

    const value = obj.getAttrWithoutException('optionalAttribute');
    if (value !== undefined) {
    // Use the value
    }
  • Searches for an entity in this block table record with the specified ID.

    Parameters

    • id: string

      The entity ID to search for

    Returns undefined | AcDbEntity

    The entity with the specified ID, or undefined if not found

    const entity = blockRecord.getIdAt('some-entity-id');
    if (entity) {
    console.log('Found entity:', entity.type);
    }