Skip to content

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

Class: McDbXlsxTable ​

2d.McDbXlsxTable

XLSX table entity class is used to display and manage tabular data content in CAD.

Description

McDbXlsxTable is a custom table entity that is suitable for mapping Excel/XLSX data structures to CAD graphic objects for display. This class can accomplish: -Analyze and save the original XLSX data in the table; -Set row height, column width, style, position, and rendering direction; -Handling cell merging, styling, and text size calculations; -In the worldDraw stage, render the table into the drawing environment; -Adapt to the interactive editing and object transformation logic in CAD.

Usage:

  1. Create an instance of McDbXlsxTable;
  2. Set core properties such as position, rowHeight, colWidth, renderDirection, etc;
  3. Transfer Base64 table data through xlsxData, or directly set the table content and style;
  4. Call worldDraw() or the drawing process to display the table in CAD;
  5. If editing is required, the style, cell data, and position can be updated synchronously and redrawn.

Summary: McDbXlsxTable is a custom entity displayed in MxCAD tables, suitable for embedding structured table content in a visual way into engineering drawings.

Example

ts
   import { MxCpp, McDbXlsxTable, MxCADUiPrPoint } from "mxcad";

//Draw a table
   async function Mx_drawTable() {
   const table: McDbXlsxTable = new McDbXlsxTable();

//Set basic attributes
table.colWidth = 5; //Default column width
table.rowHeight = 5; //Default row height
table.styleName = "STANDARD"; //Set table style
//Method 1: Create a table from an array
   const data = [
[Title 1, Title 2, Title 3, Title 4],
[Data 1, Data 2, Data 3, Data 4],
[Data 5, Data 6, Data 7, Data 8],
       [
Data 9,
Data 10,
Data 11,
       [
           {
           type: "paragraph",
           children: [
               {
               text: "ssss",
               },
           ],
           },
           {
           type: "paragraph",
           children: [
               {
               text: "666",
               },
           ],
           },
       ],
       ],
   ];
   table.setFromArray(data);

//Merge cells
   table.setMergeCells([
       {
       row: 0,
       col: 0,
       rowspan: 1,
colspan: 4, //Merge all cells in the first row as headings
       },
   ]);

//Set the value of the first line as the title
Table.setCellValue (0,0, "table title");

//Set table position
   const mxcad = MxCpp.getCurrentMxCAD();
   const getPoint = new MxCADUiPrPoint();
GetPoint.setMessage ("\ nSpecify table insertion point");
   const pt = await getPoint.go();
   table.position = pt;

//Draw a table
   mxcad.drawEntity(table); 
   }

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new McDbXlsxTable(imp?)

Parameters ​

NameType
imp?any

Overrides ​

McDbCustomEntity.constructor

Properties ​

imp ​

• imp: any = 0

Internal implementation object.

Inherited from ​

McDbCustomEntity.imp


matrix ​

• matrix: McGeMatrix3d

Accessors ​

colCount ​

• get colCount(): number

Number of columns in the table

Returns ​

number


colWidth ​

• get colWidth(): number

Table overall column width

Returns ​

number

• set colWidth(val): void

Parameters ​

NameType
valnumber

Returns ​

void


colorIndex ​

• get colorIndex(): number

Obtain object color index

Returns ​

number

Inherited from ​

McDbCustomEntity.colorIndex

• set colorIndex(val): void

Set object color index

Parameters ​

NameTypeDescription
ValnumberColorIndexType

Returns ​

void

Inherited from ​

McDbCustomEntity.colorIndex


drawOrder ​

• get drawOrder(): number

Display order of objects

Returns ​

number

Inherited from ​

McDbCustomEntity.drawOrder

• set drawOrder(order): void

Display order of objects

Parameters ​

NameTypeDescription
Ordernumbersequential value

Returns ​

void

Example

ts
import { MxCpp, MxCADSelectionSet } from "mxcad";

let ss = new MxCADSelectionSet();
If (! Await ss.userSelect) return;
//Obtain the maximum and minimum display order of objects on the current graph
let minmaxOrder = MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
//Place the object at the top.
let lOrder = minmaxOrder.maxDrawOrder + 1;
ss.forEach((id) => {
  let ent = id.getMcDbEntity();
  if (ent) {
    ent.drawOrder = lOrder;
  }
})

Inherited from ​

McDbCustomEntity.drawOrder


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 ​

McDbCustomEntity.dxf0


layer ​

• get layer(): string

Obtain the layer name of the object

Returns ​

string

Inherited from ​

McDbCustomEntity.layer

• set layer(val): void

Set object layer name

Parameters ​

NameTypeDescription
ValstringLayer Name

Returns ​

void

Inherited from ​

McDbCustomEntity.layer


layerId ​

• get layerId(): McObjectId

Get layer ID object

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.layerId

• set layerId(id): void

Set Layer Id Object

Parameters ​

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCustomEntity.layerId


linetype ​

• get linetype(): string

Obtain the object line type name

Returns ​

string

Inherited from ​

McDbCustomEntity.linetype

• set linetype(val): void

Set object line type name

Parameters ​

NameTypeDescription
ValstringLine type name

Returns ​

void

Inherited from ​

McDbCustomEntity.linetype


linetypeId ​

• get linetypeId(): McObjectId

Get entity object line type ID

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.linetypeId

• set linetypeId(id): void

Set entity object line type ID

Parameters ​

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCustomEntity.linetypeId


linetypeScale ​

• get linetypeScale(): number

Obtain the proportion of object line types

Returns ​

number

Inherited from ​

McDbCustomEntity.linetypeScale

• set linetypeScale(val): void

Set object line type scale

Parameters ​

NameTypeDescription
ValnumberLine type ratio

Returns ​

void

Inherited from ​

McDbCustomEntity.linetypeScale


lineweight ​

• get lineweight(): number

Obtain object line weight

Returns ​

number

Inherited from ​

McDbCustomEntity.lineweight

• set lineweight(val): void

Set object line weight

Parameters ​

NameTypeDescription
Valnumberline weight

Returns ​

void

Inherited from ​

McDbCustomEntity.lineweight


normal ​

• get normal(): McGeVector3d

Return the normal of the object

Returns ​

McGeVector3d

Inherited from ​

McDbCustomEntity.normal

• set normal(val): void

Set the normal of the object

Parameters ​

NameType
valMcGeVector3d

Returns ​

void

Inherited from ​

McDbCustomEntity.normal


objectName ​

• get objectName(): string

Get the object name.

Returns ​

string

Return object name

Inherited from ​

McDbCustomEntity.objectName


position ​

• get position(): McGePoint3d

Table Position and Size - Required for Rendering

Returns ​

McGePoint3d

• set position(val): void

Parameters ​

NameType
valMcGePoint3d

Returns ​

void


renderDirection ​

• get renderDirection(): TableRenderDirection

Table rendering direction

Returns ​

TableRenderDirection

• set renderDirection(val): void

Parameters ​

NameType
valTableRenderDirection

Returns ​

void


rowCount ​

• get rowCount(): number

Table rows

Returns ​

number


rowHeight ​

• get rowHeight(): number

Table overall row height

Returns ​

number

• set rowHeight(val): void

Parameters ​

NameType
valnumber

Returns ​

void


style ​

• get style(): null | Partial<Omit<ITableStyle, "name">>

Returns ​

null | Partial<Omit<ITableStyle, "name">>


styleName ​

• get styleName(): string

Table Style Name

Returns ​

string

• set styleName(val): void

Parameters ​

NameType
valstring

Returns ​

void


textStyle ​

• get textStyle(): string

Obtain the text style of the object

Returns ​

string

Inherited from ​

McDbCustomEntity.textStyle

• set textStyle(val): void

Set object text style

Parameters ​

NameTypeDescription
ValstringText style name

Returns ​

void

Inherited from ​

McDbCustomEntity.textStyle


textStyleId ​

• get textStyleId(): McObjectId

Get entity text style

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.textStyleId

• set textStyleId(id): void

Set the text style of the entity

Parameters ​

NameType
idMcObjectId

Returns ​

void

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;

Inherited from ​

McDbCustomEntity.textStyleId


thickness ​

• get thickness(): number

Obtain the thickness of the object

Returns ​

number

Inherited from ​

McDbCustomEntity.thickness

• set thickness(val): void

Set object thickness

Parameters ​

NameType
valnumber

Returns ​

void

Inherited from ​

McDbCustomEntity.thickness


trueColor ​

• get trueColor(): McCmColor

Obtain the color of the object

Returns ​

McCmColor

Inherited from ​

McDbCustomEntity.trueColor

• set trueColor(val): void

Set object color

Parameters ​

NameType
valMcCmColor

Returns ​

void

Inherited from ​

McDbCustomEntity.trueColor


visible ​

• get visible(): boolean

Is the object visible

Returns ​

boolean

Inherited from ​

McDbCustomEntity.visible

• set visible(val): void

Set whether it is visible

Parameters ​

NameTypeDescription
ValbooleanBoolean value

Returns ​

void

Inherited from ​

McDbCustomEntity.visible


xlsxData ​

• get xlsxData(): string

Returns ​

string

• set xlsxData(data): void

Parameters ​

NameType
datastring

Returns ​

void

Methods ​

IntersectWith ​

▸ IntersectWith(intersectObject, exOption): McGePoint3dArray

Intersection with other entities to obtain the intersection point

Parameters ​

NameTypeDescription
IntersectObject[McDbEntity] (2d. McDbEntity. md)The entity object that needs to intersect is the entity object
ExOptionIntersection (../enums/2d. McDb. Intersect. md)Intersection options

Returns ​

McGePoint3dArray

Obtain all intersection points

Example

ts
import { McDbLine, McDb } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
const line2 = new McDbLine(new McGePoint3d(10,10,0), new McGePoint3d(11,1,0));
const ptArr = line1.IntersectWith(line2, McDb.Intersect.kExtendBoth)

Inherited from ​

McDbCustomEntity.IntersectWith


addSelectedCell ​

▸ addSelectedCell(row, col): void

Add a cell to the selected collection

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

void


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 ​

McDbCustomEntity.assertObjectModification


calculateTableDimensions ​

▸ calculateTableDimensions(): Object

Calculate table size

Returns ​

Object

NameType
heightnumber
widthnumber

clearSelectedCell ​

▸ clearSelectedCell(): void

Clear the currently selected cell

Returns ​

void


clone ​

▸ clone(): null | McDbObject

Copy entity

Returns ​

null | McDbObject

Inherited from ​

McDbCustomEntity.clone


create ​

▸ create(imp): McDbXlsxTable

Create a new custom object (by default, call its constructor to create a new object)

Parameters ​

NameType
impany

Returns ​

McDbXlsxTable

Overrides ​

McDbCustomEntity.create


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

Create extended dictionary data for objects

Returns ​

boolean

Inherited from ​

McDbCustomEntity.createExtensionDictionary


deleteColumn ​

▸ deleteColumn(onSelectionChange?): void

Delete the selected column

Parameters ​

NameTypeDescription
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


deleteRow ​

▸ deleteRow(onSelectionChange?): void

Delete the selected row

Parameters ​

NameTypeDescription
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


deleteXData ​

▸ deleteXData(appName): boolean

Delete data related to entity specified application name

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

boolean

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.deleteXData("DataName");
if(res){
//Delete successfully
}else
//Delete failed
}

Inherited from ​

McDbCustomEntity.deleteXData


disableDisplay ​

▸ disableDisplay(isDisable): void

Disable automatic update display of objects

Parameters ​

NameTypeDescription
IsDisablebooleanDo you want to disable automatic object update display

Returns ​

void

Inherited from ​

McDbCustomEntity.disableDisplay


dwgInFields ​

▸ dwgInFields(filter): boolean

Read custom entity data fields from DWG files

Parameters ​

NameType
filterIMcDbDwgFiler

Returns ​

boolean

Overrides ​

McDbCustomEntity.dwgInFields


dwgOutFields ​

▸ dwgOutFields(filter): boolean

Write the data fields of custom entities to a DWG file

Parameters ​

NameType
filterIMcDbDwgFiler

Returns ​

boolean

Overrides ​

McDbCustomEntity.dwgOutFields


erase ​

▸ erase(): boolean

Delete object.

Returns ​

boolean

Whether the deletion was successful.

Inherited from ​

McDbCustomEntity.erase


explode ​

▸ explode(): MxCADResbuf

Break the object and return the linked list of the object's data after being broken

Returns ​

MxCADResbuf

Rebuf data

Example

ts
import { McDbEntity, MxCADResbuf } from "mxcad";
//Obtain the target object
let getEnt = new MxCADUiPrEntity();
GetEnt.setMessage ("Select object to break: ");
let id = await getEnt.go();
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
//Smash objects
      let retExplode: MxCADResbuf = ent.explode();
      if (retExplode.GetCount() == 0) return;
      let iExplodeConut = retExplode.GetCount();
      for (let j = 0; j < iExplodeConut; j++) {
          let tmpobj = retExplode.AtObject(j).val;
          if(tmpobj instanceof McDbEntity ){
              mxcad.drawEntity(tmpobj);
          }
      }

Inherited from ​

McDbCustomEntity.explode


getAllAppName ​

▸ getAllAppName(): McGeStringArray

Get the application name (AppName) of all XData records contained in the entity

Returns ​

McGeStringArray

Inherited from ​

McDbCustomEntity.getAllAppName


getAllColumnWidths ​

▸ getAllColumnWidths(): IColumnWidth[]

Get all column width settings

Returns ​

IColumnWidth[]


getAllRowHeights ​

▸ getAllRowHeights(): IRowHeight[]

Get all row height settings

Returns ​

IRowHeight[]


getArea ​

▸ getArea(): Object

Calculate Area

Returns ​

Object

Is the val area value | ret successfully obtained

NameType
retboolean
valnumber

Example

ts
import { McGePoint3d, McDbCircle } from "mxcad"

const circle = new McDbCircle(0,0,0, 20);
const area = circle.getArea();
Console.log ("Circle area: ", area)

Inherited from ​

McDbCustomEntity.getArea


getBoundingBox ​

▸ getBoundingBox(): Object

Obtain the minimum outsourcing of the object

Returns ​

Object

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Overrides ​

McDbCustomEntity.getBoundingBox


getCellAlignment ​

▸ getCellAlignment(row, col): undefined | "center" | "left" | "right"

Get the horizontal alignment of cells

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | "center" | "left" | "right"

Horizontal alignment method, if not set, returns' left '


getCellAtPoint ​

▸ getCellAtPoint(point): null | { col: number ; row: number }

Convert CAD coordinate points to cell positions in a table

Parameters ​

NameTypeDescription
Point[McGePoint3d] (2d. McGePoint3d. md)A 3D point in CAD space

Returns ​

null | { col: number ; row: number }

Cell position {row, col} or null (when the point is not within the table)


getCellBackgroundColor ​

▸ getCellBackgroundColor(row, col): undefined | null | number

Get cell background color

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | null | number

Cell background color, return null if not set


getCellBorderLineType ​

▸ getCellBorderLineType(row, col): undefined | string

Get cell border line type

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | string

Cell border line type, if not set, returns undefined


getCellBorderLineWeight ​

▸ getCellBorderLineWeight(row, col): undefined | number

Get cell border line width

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | number

Cell border line width, if not set, returns undefined


getCellFromReference ​

▸ getCellFromReference(cellRef): null | { col: number ; row: number }

Retrieve cell index from A1 format reference

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")

Returns ​

null | { col: number ; row: number }

Cell index {row, col} or null (when reference is invalid)


getCellGeometry ​

▸ getCellGeometry(row, col): null | { max: McGePoint3d ; min: McGePoint3d }

Get the geometric range of the specified cell

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

null | { max: McGePoint3d ; min: McGePoint3d }

The geometric range of the cell {min: McGePoint3d, max: McGePoint3d} or null (when the cell does not exist)


getCellReference ​

▸ getCellReference(row, col): string

Retrieve the A1 format reference of the specified cell

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

string

A1 format cell reference (e.g. "A1", "B2")


getCellStyles ​

▸ getCellStyles(): CellStyleInfo

Get the style of the cell

Returns ​

CellStyleInfo


getCellTextAngle ​

▸ getCellTextAngle(row, col): undefined | number

Get cell text angle

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | number

Cell text angle, if not set, returns undefined


getCellTextColor ​

▸ getCellTextColor(row, col): undefined | null | number

Get cell text color

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | null | number

Cell text color, return null if not set


getCellTextStyle ​

▸ getCellTextStyle(row, col): undefined | string

Get cell text style

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | string

Cell text style, if not set, returns undefined


getCellTextValue ​

▸ getCellTextValue(row, col): string

Retrieve the plain text value of the cell (extract text if in Slate format)

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

string

The plain text value of a cell


getCellValue ​

▸ getCellValue(row, col): any

Get the value of the specified cell

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

any

cell value


getCellVerticalAlignment ​

▸ getCellVerticalAlignment(row, col): undefined | "top" | "bottom" | "middle"

Get the vertical alignment of cells

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

undefined | "top" | "bottom" | "middle"

Vertical alignment method, if not set, returns' top '


getCellWorldCorners ​

▸ getCellWorldCorners(row, col): null | McGePoint3d[]

Retrieve the four corner points of the specified cell (considering merging) in the world coordinate system

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

null | McGePoint3d[]

McGePoint3d [] order: [top left, top right, bottom right, bottom left]


getColumnWidth ​

▸ getColumnWidth(col): number

Get the width of the specified column

Parameters ​

NameTypeDescription
Colnumbercolumn index (0-based)

Returns ​

number

Column width, if not set, returns to default column width


getDatabase ​

▸ getDatabase(): McDbDatabase

Get the database where the object is located

Returns ​

McDbDatabase

Return to database

Inherited from ​

McDbCustomEntity.getDatabase


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

Get the index ID of the object

Returns ​

number

Inherited from ​

McDbCustomEntity.getDatabaseIndexId


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

Obtain the extended dictionary data of the object

Returns ​

McDbDictionary

Expand dictionary data

Inherited from ​

McDbCustomEntity.getExtensionDictionary


getGripEditBasePointsIndex ​

▸ getGripEditBasePointsIndex(): number[]

Get the grip of the custom object.

Returns ​

number[]

Pinch object array

Inherited from ​

McDbCustomEntity.getGripEditBasePointsIndex


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

Get the grip of the custom object.

Returns ​

McGePoint3dArray

Pinch object array

Overrides ​

McDbCustomEntity.getGripPoints


getHandle ​

▸ getHandle(): string

Obtain object handle

Returns ​

string

Return object handle

Inherited from ​

McDbCustomEntity.getHandle


getImp ​

▸ getImp(): any

Retrieve internal implementation objects.

Returns ​

any

Internal implementation object.

Inherited from ​

McDbCustomEntity.getImp


getJson ​

▸ getJson(): string

Retrieve a string in JSON format.

Returns ​

string

A string in JSON format.

Inherited from ​

McDbCustomEntity.getJson


getMergeCells ​

▸ getMergeCells(): IMergeCellInfo[]

Get merged cell information

Returns ​

IMergeCellInfo[]


getName ​

▸ getName(): string

Get custom object name

Returns ​

string

Inherited from ​

McDbCustomEntity.getName


getObjectID ​

▸ getObjectID(): McObjectId

Get the object ID.

Returns ​

McObjectId

Object ID.

Inherited from ​

McDbCustomEntity.getObjectID


getOwnerID ​

▸ getOwnerID(): number

Obtain the ID of the object owner

Returns ​

number

Inherited from ​

McDbCustomEntity.getOwnerID


getRowHeight ​

▸ getRowHeight(row): number

Get the height of the specified row

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)

Returns ​

number

Row height, if not set, returns to default row height


getSelectCellBackgroundColor ​

▸ getSelectCellBackgroundColor(): undefined | null | number

Get the background color of the selected cell

Returns ​

undefined | null | number


getSelectCellTextColor ​

▸ getSelectCellTextColor(): undefined | null | number

Get the text color of the selected cell

Returns ​

undefined | null | number


getSelectedCell ​

▸ getSelectedCell(): null | { col: number ; row: number }

Retrieve the currently selected cell

Returns ​

null | { col: number ; row: number }

The first selected cell, if not selected, returns null


getSelectedCellCount ​

▸ getSelectedCellCount(): number

Get the number of selected cells

Returns ​

number

Number of selected cells


getSelectedCells ​

▸ getSelectedCells(): { col: number ; row: number }[]

Retrieve all selected cells

Returns ​

{ col: number ; row: number }[]

All selected cell arrays


getSelectionRange ​

▸ getSelectionRange(): null | { maxCol: number ; maxRow: number ; minCol: number ; minRow: number }

Get the range of selected cells

Returns ​

null | { maxCol: number ; maxRow: number ; minCol: number ; minRow: number }

Include the minimum and maximum row and column indexes of the selected range


getTypeName ​

▸ getTypeName(): string

Get the type name of the custom entity.

Returns ​

string

Custom entity type name

Overrides ​

McDbCustomEntity.getTypeName


getxData ​

▸ getxData(appName?): MxCADResbuf

Obtain the extended data of the object

Parameters ​

NameTypeDefault valueDescription
AppNamestring""Extended Data Name

Returns ​

MxCADResbuf

Inherited from ​

McDbCustomEntity.getxData


getxDataDouble ​

▸ getxDataDouble(appName): Object

Retrieve the double value from the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Double value

NameType
retboolean
valnumber

Inherited from ​

McDbCustomEntity.getxDataDouble


getxDataLong ​

▸ getxDataLong(appName): Object

Retrieve the long (integer) value from the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Long value

NameType
retboolean
valnumber

Inherited from ​

McDbCustomEntity.getxDataLong


getxDataPoint ​

▸ getxDataPoint(appName): Object

Retrieve point objects from the specified XData type of entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Obtain results and 3D point objects

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCustomEntity.getxDataPoint


getxDataString ​

▸ getxDataString(appName): Object

Retrieve XData information associated with a specific entity and return it in string form

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name

Returns ​

Object

Val XData information | whether ret returns success

NameType
retboolean
valstring

Inherited from ​

McDbCustomEntity.getxDataString


hasUnmergedCellsSelected ​

▸ hasUnmergedCellsSelected(): boolean

Check if any unmerged cells have been selected

Returns ​

boolean


highlight ​

▸ highlight(isHighlight): void

Set whether the object is highlighted

Parameters ​

NameTypeDescription
IsHighlightbooleanIs it highlighted

Returns ​

void

Inherited from ​

McDbCustomEntity.highlight


initTempObject ​

▸ initTempObject(imp): void

Initialize temporary objects.

Parameters ​

NameTypeDescription
'imp''any'Internal implementation object

Returns ​

void

Inherited from ​

McDbCustomEntity.initTempObject


insertColumn ​

▸ insertColumn(position, onSelectionChange?): void

Insert a column at the specified location

Parameters ​

NameTypeDescription
Position"left" \"right"
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


insertRow ​

▸ insertRow(position, onSelectionChange?): void

Insert a row at the specified location

Parameters ​

NameTypeDescription
Position"above" \"below"
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


isCellSelected ​

▸ isCellSelected(row, col): boolean

Check if the specified cell is selected

Parameters ​

NameTypeDescription
Rownumberrow index
Colnumbercolumn index

Returns ​

boolean

Was it selected


isErased ​

▸ isErased(): boolean

Has the object been deleted

Returns ​

boolean

Inherited from ​

McDbCustomEntity.isErased


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

Is there any extended dictionary data available

Returns ​

boolean

Inherited from ​

McDbCustomEntity.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 ​

McDbCustomEntity.isKindOf


isMergedCellSelected ​

▸ isMergedCellSelected(): boolean

Check if merged cells are selected

Returns ​

boolean


isNull ​

▸ isNull(): any

Determine if it is an empty object

Returns ​

any

Inherited from ​

McDbCustomEntity.isNull


mergeCells ​

▸ mergeCells(onSelectionChange?): void

Merge selected cells

Parameters ​

NameTypeDescription
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


mirror ​

▸ mirror(point1, point2): boolean

Mirror oriented object

Parameters ​

NameTypeDescription
Point1[McGePoint3d] (2d. McGePoint3d. md)Mirror Base Point
point2McGePoint3d-

Returns ​

boolean

Inherited from ​

McDbCustomEntity.mirror


move ​

▸ move(fromPoint, toPoint): boolean

move objects

Parameters ​

NameTypeDescription
From Point[McGePoint3d] (2d. McGePoint3d. md)Move the starting point
ToPoint[McGePoint3d] (2d. McGePoint3d. md)Move End Point

Returns ​

boolean

Inherited from ​

McDbCustomEntity.move


moveGripPointsAt ​

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

Move the grip of custom objects.

Parameters ​

NameTypeDescription
IIndexNumberGrip Index
DXOffsetnumberX-axis offset
DYOffsetnumberY-axis offset
DZOffsetnumberZ-axis offset

Returns ​

void

Example

ts
  import { McDbCustomEntity, MxCADWorldDraw, McDbLine } from 'mxcad';
//Create a new McDbTestLineCustomizing Entity class to inherit McDbCustomizing Entity
  class McDbTestLineCustomEntity extends McDbCustomEntity {
//Define the point object pt1 inside McDbtTestLineCustomizing Entity pt2
       private pt1: McGePoint3d = new McGePoint3d();
       private pt2: McGePoint3d = new McGePoint3d();
//Move the grip of custom objects.
       public moveGripPointsAt(iIndex: number, dXOffset: number, dYOffset: number, dZOffset: number) {
           this.assertWrite();
           if (iIndex == 0) {
           this.pt1.x += dXOffset;
           this.pt1.y += dYOffset;
           this.pt1.z += dZOffset;
           }
           else if (iIndex == 1) {
           this.pt2.x += dXOffset;
           this.pt2.y += dYOffset;
           this.pt2.z += dZOffset;
           }
       };
   }

Overrides ​

McDbCustomEntity.moveGripPointsAt


resetColumnWidth ​

▸ resetColumnWidth(col): void

Reset the width of the specified column to the default value

Parameters ​

NameTypeDescription
Colnumbercolumn index (0-based)

Returns ​

void


resetRowHeight ​

▸ resetRowHeight(row): void

Reset the height of the specified row to the default value

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)

Returns ​

void


rotate ​

▸ rotate(basePoint, dRotationAngle): boolean

Rotate object

Parameters ​

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Rotate the base point
DRotationAnglenumberRotation angle

Returns ​

boolean

Inherited from ​

McDbCustomEntity.rotate


rxInit ​

▸ rxInit(): void

Custom Entity Registration

Returns ​

void

Example

ts
import { MxFun } from 'mxdraw
//MxCAD created successfully
MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
//McDbtTestLineCustomizing Entity Custom Entity
new McDbTestLineCustomEntity().rxInit();//  Custom Entity Registration
MxFun.addCommand("MxTest_DrawCustomEntity");//  Register drawing entity command
})

Inherited from ​

McDbCustomEntity.rxInit


scaleEntity ​

▸ scaleEntity(basePoint, dScaleFactor): boolean

Scaling objects

Parameters ​

NameTypeDescription
BasePoint[McGePoint3d] (2d. McGePoint3d. md)Scale Base Point
DScaleFactornumberscaling factor (<1 zoom out;>1 zoom in)

Returns ​

boolean

Inherited from ​

McDbCustomEntity.scaleEntity


setAlignment ​

▸ setAlignment(alignment, onSelectionChange?): void

Set the horizontal alignment of the selected cells

Parameters ​

NameTypeDescription
Alignment"center" \"left" \
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


setBatchCellAlignment ​

▸ setBatchCellAlignment(cells, alignment): void

Batch Set Cell Horizontal Alignment Method

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
Alignment"center" \"left" \

Returns ​

void


setBatchCellBackgroundColor ​

▸ setBatchCellBackgroundColor(cells, color): void

Batch set cell background color

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
colorundefined \null \

Returns ​

void


setBatchCellBorderLineType ​

▸ setBatchCellBorderLineType(cells, lineType): void

Batch set cell border line type

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
LineTypestringBorder line type (such as "Continuous", "Dashed", "Dotted", etc.)

Returns ​

void


setBatchCellBorderLineWeight ​

▸ setBatchCellBorderLineWeight(cells, lineWeight): void

Batch set cell border line width

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
LineWeightNumberBorder Width (in millimeters)

Returns ​

void


setBatchCellTextAngle ​

▸ setBatchCellTextAngle(cells, textAngle): void

Batch Set Cell Text Angle

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
TextAnglenumberText angle (0-360 degrees)

Returns ​

void


setBatchCellTextColor ​

▸ setBatchCellTextColor(cells, color): void

Batch set cell text color

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
colorundefined \null \

Returns ​

void


setBatchCellTextStyle ​

▸ setBatchCellTextStyle(cells, textStyle): void

Batch set cell text style

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
TextStylestringText Style Name

Returns ​

void


setBatchCellVerticalAlignment ​

▸ setBatchCellVerticalAlignment(cells, verticalAlignment): void

Batch set vertical alignment of cells

Parameters ​

NameTypeDescription
Cells(string \\ {col: number; row: number}) []
Vertical Alignment"top" \"bottom" \

Returns ​

void


setCellAlignment ​

▸ setCellAlignment(row, col, alignment): void

Set the horizontal alignment of cells

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
Alignment"center" \"left" \

Returns ​

void


setCellAlignmentByRef ​

▸ setCellAlignmentByRef(cellRef, alignment): boolean

Set the horizontal alignment of cells through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
Alignment"center" \"left" \

Returns ​

boolean

Is the setting successful


setCellBackgroundColor ​

▸ setCellBackgroundColor(row, col, color): void

Set cell background color

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
colorundefined \null \

Returns ​

void


setCellBackgroundColorByRef ​

▸ setCellBackgroundColorByRef(cellRef, color): boolean

Set cell background color through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
colorundefined \null \

Returns ​

boolean

Is the setting successful


setCellBorderLineType ​

▸ setCellBorderLineType(row, col, lineType): void

Set cell border line type

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
LineTypestringBorder line type (such as "Continuous", "Dashed", "Dotted", etc.)

Returns ​

void


setCellBorderLineTypeByRef ​

▸ setCellBorderLineTypeByRef(cellRef, lineType): boolean

Set cell border line type through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
LineTypestringBorder line type (such as "Continuous", "Dashed", "Dotted", etc.)

Returns ​

boolean

Is the setting successful


setCellBorderLineWeight ​

▸ setCellBorderLineWeight(row, col, lineWeight): void

Set cell border line width

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
LineWeightNumberBorder Width (in millimeters)

Returns ​

void


setCellBorderLineWeightByRef ​

▸ setCellBorderLineWeightByRef(cellRef, lineWeight): boolean

Set cell border line width through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
LineWeightNumberBorder Width (in millimeters)

Returns ​

boolean

Is the setting successful


setCellTextAngle ​

▸ setCellTextAngle(row, col, textAngle): void

Set cell text angle

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
TextAnglenumberText angle (0-360 degrees)

Returns ​

void


setCellTextAngleByRef ​

▸ setCellTextAngleByRef(cellRef, textAngle): boolean

Set the cell text angle through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
TextAnglenumberText angle (0-360 degrees)

Returns ​

boolean

Is the setting successful


setCellTextColor ​

▸ setCellTextColor(row, col, color): void

Set cell text color

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
colorundefined \null \

Returns ​

void


setCellTextColorByRef ​

▸ setCellTextColorByRef(cellRef, color): boolean

Set cell text color through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
colorundefined \null \

Returns ​

boolean

Is the setting successful


setCellTextStyle ​

▸ setCellTextStyle(row, col, textStyle): void

Set cell text style

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
TextStylestringText Style Name

Returns ​

void


setCellTextStyleByRef ​

▸ setCellTextStyleByRef(cellRef, textStyle): boolean

Set cell text style through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
TextStylestringText Style Name

Returns ​

boolean

Is the setting successful


setCellValue ​

▸ setCellValue(row, col, value): void

Set the value of the specified cell

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
valueanyCell value (Slate format or plain text)

Returns ​

void


setCellVerticalAlignment ​

▸ setCellVerticalAlignment(row, col, verticalAlignment): void

Set the vertical alignment of cells

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)
Vertical Alignment"top" \"bottom" \

Returns ​

void


setCellVerticalAlignmentByRef ​

▸ setCellVerticalAlignmentByRef(cellRef, verticalAlignment): boolean

Set the vertical alignment of cells through A1 reference format

Parameters ​

NameTypeDescription
CellRefstringA1 format cell reference (e.g. "A1", "B2")
Vertical Alignment"top" \"bottom" \

Returns ​

boolean

Is the setting successful


setColumnWidth ​

▸ setColumnWidth(col, width): void

Set the width of the specified column

Parameters ​

NameTypeDescription
Colnumbercolumn index (0-based)
Widthnumbercolumn width (in units consistent with style.colWidth)

Returns ​

void


setFromArray ​

▸ setFromArray(data): void

Parameters ​

NameType
dataany[][]

Returns ​

void


setFromJson ​

▸ setFromJson(jsonArray): void

Parameters ​

NameType
jsonArrayany[]

Returns ​

void


setFromWorkbook ​

▸ setFromWorkbook(processedData): void

Parameters ​

NameType
processedDataICellStyleInfo

Returns ​

void


setJson ​

▸ setJson(str): boolean

Set a string in JSON format.

Parameters ​

NameTypeDescription
StrstringJSON formatted string

Returns ​

boolean

Is the setting successful.

Inherited from ​

McDbCustomEntity.setJson


setMergeCells ​

▸ setMergeCells(mergeCells): void

Set merged cell information

Parameters ​

NameType
mergeCellsIMergeCellInfo[]

Returns ​

void


setRowHeight ​

▸ setRowHeight(row, height): void

Set the height of the specified row

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Heightnumberline height (unit consistent with style.rowHeight)

Returns ​

void


setSelectCellBackgroundColor ​

▸ setSelectCellBackgroundColor(color, onSelectionChange?): void

Set the background color of the selected cell

Parameters ​

NameTypeDescription
Colorundefinednull
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


setSelectCellTextColor ​

▸ setSelectCellTextColor(color, onSelectionChange?): void

Set the text color of the selected cell

Parameters ​

NameTypeDescription
Colorundefinednull
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


setSelectedCell ​

▸ setSelectedCell(row, col): void

Set the currently selected cell

Parameters ​

NameTypeDescription
Rownumberrow index (0-based)
Colnumbercolumn index (0-based)

Returns ​

void


setSelectedCells ​

▸ setSelectedCells(cells): void

Set multiple selected cells

Parameters ​

NameTypeDescription
cells\ {col : number ; row : number `} []Cell position array [{row, col},...]

Returns ​

void


setStyle ​

▸ setStyle(style): void

Set the table style

Parameters ​

NameType
stylePartial<Omit<ITableStyle, "name">>

Returns ​

void


setVerticalAlignment ​

▸ setVerticalAlignment(alignment, onSelectionChange?): void

Set the vertical alignment of the selected cells

Parameters ​

NameTypeDescription
Alignment"top" \"bottom" \
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


setxData ​

▸ setxData(xdata): boolean

Set extended data for objects

Parameters ​

NameTypeDescription
Xdata[MxCADResbuf] (2d. MxCADResbuf. md)Extended data linked list

Returns ​

boolean

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

//Set extended data
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
ent.setxData(new MxCADResbuf([{type:DxfCode.kExDataName,val:"DataName"},{type:DxfCode.kString,val:"yyyyy"}]));

Inherited from ​

McDbCustomEntity.setxData


setxDataDouble ​

▸ setxDataDouble(appName, val): boolean

Set the double value in the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name
Valnumberdouble value

Returns ​

boolean

Boolean value

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataDouble("DataName", 0);
if(res){
//Setting successful
}else{
//Setting failed
}

Inherited from ​

McDbCustomEntity.setxDataDouble


setxDataLong ​

▸ setxDataLong(appName, val): boolean

Set the long (integer) value in the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name
Valnumberlong value

Returns ​

boolean

Long value

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";

let selEntity = new MxCADUiPrEntity();
SelEntity. setMessage ("Select Object");
let id = await selEntity.go();
if (!id.isValid()) return;
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
const res = ent.setxDataLong("DataName", 123456);
if(res){
//Setting successful
}else{
//Setting failed
}

Inherited from ​

McDbCustomEntity.setxDataLong


setxDataPoint ​

▸ setxDataPoint(appName, val): boolean

Set the point object in the specified XData type of the entity

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name
Val[McGePoint3d] (2d. McGePoint3d. md)Point Object

Returns ​

boolean

Obtain results and 3D point objects

Inherited from ​

McDbCustomEntity.setxDataPoint


setxDataString ​

▸ setxDataString(appName, val): boolean

Set XData information associated with a specific entity and set it in string form

Parameters ​

NameTypeDescription
AppNamestringExtended Data Name
Valstringstring value

Returns ​

boolean

Is the setting successful

Inherited from ​

McDbCustomEntity.setxDataString


syncData ​

▸ syncData(toCpp?): boolean

JS object data and McDbCCustoms Entity: Synchronization of m_mapData.

Parameters ​

NameTypeDefault value
toCppbooleantrue

Returns ​

boolean

Inherited from ​

McDbCustomEntity.syncData


transformBy ​

▸ transformBy(_mat): boolean

Get custom object matrix coordinate transformation

Parameters ​

NameType
_matMcGeMatrix3d

Returns ​

boolean

Overrides ​

McDbCustomEntity.transformBy


unErase ​

▸ unErase(): boolean

Anti delete object.

Returns ​

boolean

Inherited from ​

McDbCustomEntity.unErase


unMergeCells ​

▸ unMergeCells(onSelectionChange?): void

Cancel merging of selected cells

Parameters ​

NameTypeDescription
onSelectionChange? (cells: \ {col : number ; row : number } [])=> void `Optional selection change callback

Returns ​

void


updateDisplay ​

▸ updateDisplay(): void

Display the updated display of the calling object

Returns ​

void

Inherited from ​

McDbCustomEntity.updateDisplay


worldDraw ​

▸ worldDraw(draw): void

Draw custom entities

Parameters ​

NameType
drawMxCADWorldDraw

Returns ​

void

Overrides ​

McDbCustomEntity.worldDraw