Skip to content

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbLayerTableRecord

Class: McDbLayerTableRecord ​

2d.McDbLayerTableRecord

McDbLayerTableRecord is a single record in a layer table used to save and manage the properties of layers.

Description

This class is used to describe a layer, including layer name, color, line type, locked state, frozen state, and whether it is turned off or not. It can accomplish: -Create and name layers; -Set layer color, line width, line type, and printability; -Control whether layers are frozen, locked, or closed; -Add layer objects to the layer table and use them for subsequent entity assignment.

Usage:

  1. Create an instance of McDbLayerTableRecord;
  2. Set properties such as name/color/lineWeight/isLocked;
  3. Insert into the layer table;
  4. Use its object ID to specify a layer for the entity.

Summary: In practical development, McDbLayerTableRecord is the most fine-grained object for layer attribute control, suitable for unified management of layer states and display rules.

Example

ts
import { MxCpp, McDbLayerTableRecord, McCmColor, McDb } from "mxcad";

//Create and configure layer records.
async function testLayerRecord() {
  const mxcad = MxCpp.getCurrentMxCAD();
//Construct a new layer table to record objects
  const layer = new McDbLayerTableRecord()
//Set layer color
  layer.color = new McCmColor(0, 0, 0)
//Set whether the layer is frozen
  layer.isFrozen = true
//Set whether the layer is locked
  layer.isLocked = true
//Set whether the layer is turned off
  layer.isOff = true
//Set layer line width
  layer.lineWeight = McDb.LineWeight.kLnWt018
//Set layer name
Layer.name="Layer Name"
//Retrieve the current layer table
  const layerTable = mxcad.getDatabase().getLayerTable();
//Add layers to the chart
  const objId = layerTable.add(layer)
}

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new McDbLayerTableRecord(imp?)

Constructor.

Parameters ​

NameTypeDescription
imp?AnyInternal implementation object

Overrides ​

McDbObject.constructor

Properties ​

imp ​

• imp: any = 0

Internal implementation object.

Inherited from ​

McDbObject.imp

Accessors ​

color ​

• get color(): McCmColor

Get or set the layer color.

Returns ​

McCmColor

• set color(val): void

Parameters ​

NameType
valMcCmColor

Returns ​

void


dxf0 ​

• get dxf0(): string

Obtain the type name of the object's DXF group code, which is the same as the DXF group code in AutoCAD. For example, the type name of the line is McDbLine, and the group code value for DXF0 is: LINE and DXF0 group code values can be used for type filtering when constructing sets.

Returns ​

string

Inherited from ​

McDbObject.dxf0


isFrozen ​

• get isFrozen(): boolean

Get or set whether the layer is frozen.

Returns ​

boolean

• set isFrozen(val): void

Parameters ​

NameType
valboolean

Returns ​

void


isLocked ​

• get isLocked(): boolean

Get or set whether the layer is locked.

Returns ​

boolean

• set isLocked(val): void

Parameters ​

NameType
valboolean

Returns ​

void


isOff ​

• get isOff(): boolean

Get or set whether the layer is turned off.

Returns ​

boolean

• set isOff(val): void

Parameters ​

NameType
valboolean

Returns ​

void


isPlottable ​

• get isPlottable(): boolean

Getting or setting layers is printable.

Returns ​

boolean

• set isPlottable(val): void

Parameters ​

NameType
valboolean

Returns ​

void


lineWeight ​

• get lineWeight(): LineWeight

Get or set layer line width.

Returns ​

LineWeight

• set lineWeight(val): void

Parameters ​

NameType
valLineWeight

Returns ​

void


linetypeObjectId ​

• get linetypeObjectId(): McObjectId

Get or set the layer line type object ID.

Returns ​

McObjectId

• set linetypeObjectId(val): void

Parameters ​

NameType
valMcObjectId

Returns ​

void


name ​

• get name(): string

Get or set the layer name.

Returns ​

string

• set name(val): void

Parameters ​

NameType
valstring

Returns ​

void


objectName ​

• get objectName(): string

Get the object name.

Returns ​

string

Return object name

Inherited from ​

McDbObject.objectName

Methods ​

assertObjectModification ​

▸ assertObjectModification(autoUndo?): number

Setting the state of the object to be changed can automatically trigger the update display function to update the display. For example, if the block table record is updated and the block reference needs to be notified to update the display, this function can be called.

Parameters ​

NameTypeDefault valueDescription
AutoUndobooleanfalseShould this modification automatically support undo? Default is false

Returns ​

number

Inherited from ​

McDbObject.assertObjectModification


clone ​

▸ clone(): null | McDbObject

Clone objects.

Returns ​

null | McDbObject

The cloned object.

Inherited from ​

McDbObject.clone


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

Create extended dictionary data for objects

Returns ​

boolean

Inherited from ​

McDbObject.createExtensionDictionary


erase ​

▸ erase(): boolean

Delete object.

Returns ​

boolean

Whether the deletion was successful.

Inherited from ​

McDbObject.erase


getDatabase ​

▸ getDatabase(): McDbDatabase

Get the database where the object is located

Returns ​

McDbDatabase

Return to database

Inherited from ​

McDbObject.getDatabase


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

Get the index ID of the object

Returns ​

number

Inherited from ​

McDbObject.getDatabaseIndexId


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Returns ​

McDbDictionary

Expand dictionary data

Inherited from ​

McDbObject.getExtensionDictionary


getGripEditBasePointsIndex ​

▸ getGripEditBasePointsIndex(): number[]

Retrieve the edit base point index corresponding to the grip of the object.

Returns ​

number[]

Inherited from ​

McDbObject.getGripEditBasePointsIndex


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

Get the grip array of the object

Returns ​

McGePoint3dArray

Inherited from ​

McDbObject.getGripPoints


getHandle ​

▸ getHandle(): string

Obtain object handle

Returns ​

string

Return object handle

Inherited from ​

McDbObject.getHandle


getImp ​

▸ getImp(): any

Retrieve internal implementation objects.

Returns ​

any

Internal implementation object.

Inherited from ​

McDbObject.getImp


getJson ​

▸ getJson(): string

Retrieve a string in JSON format.

Returns ​

string

A string in JSON format.

Inherited from ​

McDbObject.getJson


getObjectID ​

▸ getObjectID(): McObjectId

Get the object ID.

Returns ​

McObjectId

Object ID.

Inherited from ​

McDbObject.getObjectID


getOwnerID ​

▸ getOwnerID(): number

Obtain the ID of the object owner

Returns ​

number

Inherited from ​

McDbObject.getOwnerID


initTempObject ​

▸ initTempObject(imp): void

Initialize temporary objects.

Parameters ​

NameTypeDescription
'imp''any'Internal implementation object

Returns ​

void

Inherited from ​

McDbObject.initTempObject


isErased ​

▸ isErased(): boolean

Has the object been deleted

Returns ​

boolean

Inherited from ​

McDbObject.isErased


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Returns ​

boolean

Inherited from ​

McDbObject.isHaveExtensionDictionary


isKindOf ​

▸ isKindOf(sObjectName): boolean

Determine object type

Parameters ​

NameTypeDescription
SOrtNamestringType Name

Returns ​

boolean

Return whether the object is of the target type

Inherited from ​

McDbObject.isKindOf


isNull ​

▸ isNull(): any

Determine if it is an empty object

Returns ​

any

Inherited from ​

McDbObject.isNull


moveGripPointsAt ​

▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any

Grips for moving objects

Parameters ​

NameTypeDescription
IIndexNumberIndex
DXOffsetnumberX-axis offset
DYOffsetnumberY-axis offset
DZOffsetnumberZ-axis offset

Returns ​

any

Inherited from ​

McDbObject.moveGripPointsAt


setJson ​

▸ setJson(str): boolean

Set a string in JSON format.

Parameters ​

NameTypeDescription
StrstringJSON formatted string

Returns ​

boolean

Is the setting successful.

Inherited from ​

McDbObject.setJson


unErase ​

▸ unErase(): boolean

Anti delete object.

Returns ​

boolean

Inherited from ​

McDbObject.unErase