[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbLayerTableRecord
Class: McDbLayerTableRecord
2d.McDbLayerTableRecord
Represents a layer table that records objects and implements attribute related operation functions for layers.
Example
//Add Layer
import { McCmColor, MxCpp, McDbLayerTableRecord, McDb } from "mxcad"
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)
mxcad.updateDisplay()
Hierarchy
↳
McDbLayerTableRecord
Table of contents
Constructors
Properties
Accessors
Methods
- assertObjectModification
- clone
- createExtensionDictionary
- erase
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripPoints
- getHandle
- getImp
- getJson
- getObjectID
- getOwnerID
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- moveGripPointsAt
- setJson
- unErase
Constructors
constructor
• new McDbLayerTableRecord(imp?
)
Constructor.
Parameters
Name | Type | Description |
---|---|---|
imp? | Any | Internal implementation object |
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord()
Overrides
Properties
imp
• imp: any
= 0
Internal implementation object.
Inherited from
Accessors
color
• get
color(): McCmColor
Get or set the layer color.
Returns
Example
import { McDbLayerTableRecord, McCmColor } from "mxcad";
const layerRec = new McDbLayerTableRecord();
layerRec.color = new McCmColor(255,255,255);
console.log(layerRec.color) //(255,255,255)
• set
color(val
): void
Parameters
Name | Type |
---|---|
val | McCmColor |
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
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord();
layerRec.isFrozen = true;
console.log(layerRec.isFrozen)//true
• set
isFrozen(val
): void
Parameters
Name | Type |
---|---|
val | boolean |
Returns
void
isLocked
• get
isLocked(): boolean
Get or set whether the layer is locked.
Returns
boolean
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord();
layerRec.isLocked = true;
console.log(layerRec.isLocked)//true
• set
isLocked(val
): void
Parameters
Name | Type |
---|---|
val | boolean |
Returns
void
isOff
• get
isOff(): boolean
Get or set whether the layer is turned off.
Returns
boolean
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord();
layerRec.isOff = true;
console.log(layerRec.isOff)//true
• set
isOff(val
): void
Parameters
Name | Type |
---|---|
val | boolean |
Returns
void
lineWeight
• get
lineWeight(): LineWeight
Get or set layer line width.
Returns
Example
import { McDbLayerTableRecord, McDb } from "mxcad";
const layerRec = new McDbLayerTableRecord();
layerRec.lineWeight = McDb.LineWeight.kLnWt015;
console.log(layerRec.lineWeight)//15
• set
lineWeight(val
): void
Parameters
Name | Type |
---|---|
val | LineWeight |
Returns
void
linetypeObjectId
• get
linetypeObjectId(): McObjectId
Get or set the layer line type object ID.
Returns
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord();
console.log(layerRec.linetypeObjectId)
• set
linetypeObjectId(val
): void
Parameters
Name | Type |
---|---|
val | McObjectId |
Returns
void
name
• get
name(): string
Get or set the layer name.
Returns
string
Example
import { McDbLayerTableRecord } from "mxcad";
const layerRec = new McDbLayerTableRecord();
LayerRec.name="Test Layer";
Console. log (layerRec. name)//Test layer
• set
name(val
): void
Parameters
Name | Type |
---|---|
val | string |
Returns
void
objectName
• get
objectName(): string
Get the object name.
Returns
string
Return object name
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.objectName);
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
Name | Type | Default value |
---|---|---|
autoUndo | boolean | false |
Returns
number
Example
//Assuming obj is a database object
obj.assertObjectModification()
Inherited from
McDbObject.assertObjectModification
clone
▸ clone(): null
| McDbObject
Clone objects.
Returns
null
| McDbObject
The cloned object.
Example
//Assuming obj is a database object
const obj_clone = obj.clone();
Inherited from
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.createExtensionDictionary();
Inherited from
McDbObject.createExtensionDictionary
erase
▸ erase(): boolean
Delete object.
Returns
boolean
Whether the deletion was successful.
Example
//Assuming obj is a database object
const res = obj.erase();
console.log(res);
Inherited from
getDatabase
▸ getDatabase(): McDbDatabase
Get the database where the object is located
Returns
Return to database
Example
//Assuming obj is a database object
const data = obj.getDatabase();
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
Get the index ID of the object
Returns
number
Example
//Assuming obj is a database object
const id = obj.getDatabaseIndexId();
Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
Obtain the extended dictionary data of the object
Returns
Expand dictionary data
Example
//Assuming obj is a database object
const id = obj.getOwnerID();
Inherited from
McDbObject.getExtensionDictionary
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the control points of the object
Returns
Example
//Assuming obj is a database object
const ptArr = obj.getGripPoints();
Inherited from
getHandle
▸ getHandle(): string
Obtain object handle
Returns
string
Return object handle
Example
//Assuming obj is a database object
const handle = obj.getHandle();
Inherited from
getImp
▸ getImp(): any
Retrieve internal implementation objects.
Returns
any
Internal implementation object.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let imp = obj.getImp();
Inherited from
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Returns
string
A string in JSON format.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const json = obj.getJson()
Inherited from
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Returns
Object ID.
Example
import { McDbObject } from "mxcad";
const id = obj.getObjectID();
Inherited from
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Returns
number
Example
//Assuming obj is a database object
const id = obj.getOwnerID();
Inherited from
initTempObject
▸ initTempObject(imp
): void
Initialize temporary objects.
Parameters
Name | Type | Description |
---|---|---|
'imp' | 'any' | Internal implementation object |
Returns
void
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
obj.initTempObject()
Inherited from
isErased
▸ isErased(): boolean
Has the object been deleted
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.isErased();
console.log(res);
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
Is there any extended dictionary data available
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.isHaveExtensionDictionary();
Inherited from
McDbObject.isHaveExtensionDictionary
isKindOf
▸ isKindOf(sObjectName
): boolean
Determine object type
Parameters
Name | Type | Description |
---|---|---|
SOrtName | string | Type Name |
Returns
boolean
Return whether the object is of the target type
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
let isKind = obj.isKindOf('SomeObjectType');
console.log(isKind); // Output: True or false
Inherited from
isNull
▸ isNull(): any
Determine if it is an empty object
Returns
any
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
console.log(obj.isNull()); // Output: True or false
Inherited from
moveGripPointsAt
▸ moveGripPointsAt(iIndex
, dXOffset
, dYOffset
, dZOffset
): any
Control points for moving objects
Parameters
Name | Type | Description |
---|---|---|
IIndex | Number | Index |
DXOffset | number | X-axis offset |
DYOffset | number | Y-axis offset |
DZOffset | number | Z-axis offset |
Returns
any
Example
//Assuming obj is a database object
obj.moveGripPointsAt(1,10,10,10);
Inherited from
setJson
▸ setJson(str
): boolean
Set a string in JSON format.
Parameters
Name | Type | Description |
---|---|---|
Str | string | JSON formatted string |
Returns
boolean
Is the setting successful.
Example
import { McRxObject } from 'mxcad';
let obj = new McRxObject();
const res = obj.setJson('{"key": "value"}');
console.log(res)
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.unErase();
console.log(res);