Represents a record in the layer table.

This class contains information about a layer in the drawing database, including color, visibility settings, linetype, and other layer properties. Layers are used to organize and control the display of entities in the drawing.

const layer = new AcDbLayerTableRecord({
name: 'MyLayer',
color: new AcCmColor(255, 0, 0), // Red
isOff: false,
isPlottable: true
});

Hierarchy (View Summary)

Constructors

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 isHidden(): boolean
  • Gets or sets whether this layer is hidden.

    When a layer is hidden, it isn't shown in the user interface of the host application, but entities on the layer are still displayed.

    Returns boolean

    True if the layer is hidden, false otherwise

    if (layer.isHidden) {
    console.log('Layer is hidden from UI');
    }
    layer.isHidden = true;
  • set isHidden(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get isPlottable(): boolean
  • Gets or sets whether this layer is plottable.

    When a layer is plottable, its entities will be included when the drawing is plotted or printed.

    Returns boolean

    True if the layer is plottable, false otherwise

    if (layer.isPlottable) {
    console.log('Layer will be included in plots');
    }
    layer.isPlottable = false;
  • set isPlottable(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • 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';
    
  • get standardFlags(): number
  • Gets or sets the standard flags for this layer.

    Standard flags are bit-coded values:

    • 1 = Layer is frozen; otherwise layer is thawed
    • 2 = Layer is frozen by default in new viewports
    • 4 = Layer is locked
    • 16 = If set, table entry is externally dependent on an xref
    • 32 = If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved
    • 64 = If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited

    Returns number

    The standard flags value

    const flags = layer.standardFlags;
    layer.standardFlags = 1; // Freeze the layer
  • set standardFlags(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • 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
    }