Skip to content
On this page

mxcad_2d API 文档 / 2d / McDbLayerTableRecord

Class: McDbLayerTableRecord

2d.McDbLayerTableRecord

表示一个图层表记录对象,实现了对图层的属性相关操作函数。

Example

ts
//添加图层
import { McCmColor, MxCpp, McDbLayerTableRecord, McDb } from "mxcad"

const mxcad = MxCpp.getCurrentMxCAD();
// 构造新图层表记录对象
const layer = new McDbLayerTableRecord()
// 设置图层颜色
layer.color = new McCmColor(0, 0, 0)
// 设置图层是否被冻结
layer.isFrozen = true
// 设置图层是否被锁定
layer.isLocked = true
// 设置图层是否被关闭
layer.isOff = true
// 设置图层线宽
layer.lineWeight = McDb.LineWeight.kLnWt018
// 设置图层名
layer.name = "图层名称"
// 获取当前图层表
const layerTable = mxcad.getDatabase().getLayerTable();
// 向图表中添加图层
const objId = layerTable.add(layer)
mxcad.updateDisplay()

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbLayerTableRecord(imp?)

构造函数。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord()

Parameters

NameTypeDescription
imp?any内部实现对象。

Overrides

McDbObject.constructor

Properties

imp

imp: any = 0

内部实现对象。

Inherited from

McDbObject.imp

Accessors

color

get color(): McCmColor

获取或设置图层颜色。

Example

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

const layerRec = new McDbLayerTableRecord();
layerRec.color = new McCmColor(255,255,255);
console.log(layerRec.color) //(255,255,255)

Returns

McCmColor

set color(val): void

Parameters

NameType
valMcCmColor

Returns

void


dxf0

get dxf0(): string

得到对象的DXF组码的类型名,这个和AutoCAD中的DXF组码是一样。 比如直线的类型名为:McDbLine,DXF0组码值: LINE,DXF0组码值可以用来构造集时的类型过滤。

Returns

string

Inherited from

McDbObject.dxf0


isFrozen

get isFrozen(): boolean

获取或设置图层是否被冻结。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord();
layerRec.isFrozen = true;
console.log(layerRec.isFrozen)//true

Returns

boolean

set isFrozen(val): void

Parameters

NameType
valboolean

Returns

void


isLocked

get isLocked(): boolean

获取或设置图层是否被锁定。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord();
layerRec.isLocked = true;
console.log(layerRec.isLocked)//true

Returns

boolean

set isLocked(val): void

Parameters

NameType
valboolean

Returns

void


isOff

get isOff(): boolean

获取或设置图层是否被关闭。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord();
layerRec.isOff = true;
console.log(layerRec.isOff)//true

Returns

boolean

set isOff(val): void

Parameters

NameType
valboolean

Returns

void


lineWeight

get lineWeight(): LineWeight

获取或设置图层线宽。

Example

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

const layerRec = new McDbLayerTableRecord();
layerRec.lineWeight = McDb.LineWeight.kLnWt015;
console.log(layerRec.lineWeight)//15

Returns

LineWeight

set lineWeight(val): void

Parameters

NameType
valLineWeight

Returns

void


linetypeObjectId

get linetypeObjectId(): McObjectId

获取或设置图层线型对象 ID。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord();
console.log(layerRec.linetypeObjectId)

Returns

McObjectId

set linetypeObjectId(val): void

Parameters

NameType
valMcObjectId

Returns

void


name

get name(): string

获取或设置图层名称。

Example

ts
import { McDbLayerTableRecord } from "mxcad";

const layerRec = new McDbLayerTableRecord();
layerRec.name = "测试图层";
console.log(layerRec.name)//测试图层

Returns

string

set name(val): void

Parameters

NameType
valstring

Returns

void


objectName

get objectName(): string

获取对象名称。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.objectName);

Returns

string

返回对象名

Inherited from

McDbObject.objectName

Methods

assertObjectModification

assertObjectModification(autoUndo?): number

设置对象被改变的状态,可自动触发更新显示函数,更新显示。 比如块表记录更新了,需要通知块引用更新显示,可以调用该函数。

Example

ts
//假设obj为一个数据库对象
obj.assertObjectModification()

Parameters

NameTypeDefault value
autoUndobooleanfalse

Returns

number

Inherited from

McDbObject.assertObjectModification


clone

clone(): null | McDbObject

克隆对象。

Example

ts
//假设obj为一个数据库对象
const obj_clone = obj.clone();

Returns

null | McDbObject

克隆出的对象。

Inherited from

McDbObject.clone


createExtensionDictionary

createExtensionDictionary(): boolean

创建对象的扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const res = obj.createExtensionDictionary();

Returns

boolean

Inherited from

McDbObject.createExtensionDictionary


erase

erase(): boolean

删除对象。

Example

ts
//假设obj为一个数据库对象
const res = obj.erase();
console.log(res);

Returns

boolean

是否删除成功。

Inherited from

McDbObject.erase


getDatabase

getDatabase(): McDbDatabase

得到对象所在的数据库

Example

ts
//假设obj为一个数据库对象
const data = obj.getDatabase();

Returns

McDbDatabase

返回数据库

Inherited from

McDbObject.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

获取对象的索引ID

Example

ts
//假设obj为一个数据库对象
const id = obj.getDatabaseIndexId();

Returns

number

Inherited from

McDbObject.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

得到对象的扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const id = obj.getOwnerID();

Returns

McDbDictionary

扩展字典数据

Inherited from

McDbObject.getExtensionDictionary


getGripPoints

getGripPoints(): McGePoint3dArray

获取对象的控制点

Example

ts
//假设obj为一个数据库对象
const ptArr = obj.getGripPoints();

Returns

McGePoint3dArray

Inherited from

McDbObject.getGripPoints


getHandle

getHandle(): string

得到对象句柄

Example

ts
//假设obj为一个数据库对象
const handle = obj.getHandle();

Returns

string

返回对象句柄

Inherited from

McDbObject.getHandle


getImp

getImp(): any

获取内部实现对象。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let imp = obj.getImp();

Returns

any

内部实现对象。

Inherited from

McDbObject.getImp


getJson

getJson(): string

获取 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const json = obj.getJson()

Returns

string

JSON 格式的字符串。

Inherited from

McDbObject.getJson


getObjectID

getObjectID(): McObjectId

获取对象 ID。

Example

ts
import { McDbObject } from "mxcad";
const id = obj.getObjectID();

Returns

McObjectId

对象 ID。

Inherited from

McDbObject.getObjectID


getOwnerID

getOwnerID(): number

得到对象拥用者的id

Example

ts
//假设obj为一个数据库对象
const id = obj.getOwnerID();

Returns

number

Inherited from

McDbObject.getOwnerID


initTempObject

initTempObject(imp): void

初始化临时对象。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
obj.initTempObject()

Parameters

NameTypeDescription
impany内部实现对象。

Returns

void

Inherited from

McDbObject.initTempObject


isErased

isErased(): boolean

对象是否已经删除

Example

ts
//假设obj为一个数据库对象
const res = obj.isErased();
console.log(res);

Returns

boolean

Inherited from

McDbObject.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Example

ts
//假设obj为一个数据库对象
const res = obj.isHaveExtensionDictionary();

Returns

boolean

Inherited from

McDbObject.isHaveExtensionDictionary


isKindOf

isKindOf(sObjectName): boolean

判断对象类型

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); // 输出: true 或 false

Parameters

NameTypeDescription
sObjectNamestring类型名

Returns

boolean

返回对象是否是目标类型

Inherited from

McDbObject.isKindOf


isNull

isNull(): any

判断是否为空对象

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
console.log(obj.isNull()); // 输出: true 或 false

Returns

any

Inherited from

McDbObject.isNull


moveGripPointsAt

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

移动对象的控制点

Example

ts
//假设obj为一个数据库对象
obj.moveGripPointsAt(1,10,10,10);

Parameters

NameTypeDescription
iIndexnumber索引
dXOffsetnumberX轴偏移量
dYOffsetnumberY轴偏移量
dZOffsetnumberZ轴偏移量

Returns

any

Inherited from

McDbObject.moveGripPointsAt


setJson

setJson(str): boolean

设置 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)

Parameters

NameTypeDescription
strstringJSON 格式的字符串。

Returns

boolean

是否设置成功。

Inherited from

McDbObject.setJson


unErase

unErase(): boolean

反删除对象。

Example

ts
//假设obj为一个数据库对象
const res = obj.unErase();
console.log(res);

Returns

boolean

Inherited from

McDbObject.unErase