[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McDbCustomEntity
Class: McDbCustomEntity
2d.McDbCustomEntity
Custom entity base class, used to extend new entity types in MxCAD and implement custom drawing, data persistence, and editing behaviors.
Description
McDbCustomEntity is the base class for all custom CAD entities, typically used to create objects with special geometric structures, extended properties, or special interaction logic. This class allows developers to customize: -Entity type name and instance creation logic; -Field read-write logic in DWG files; -Graphic drawing logic; -Pinch editing and object transformation logic; -The behavior of object cloning and synchronization to underlying C++data.
By inheriting it, developers can create non-standard entities such as custom annotations, symbols, feature lines, contour lines, etc., and integrate them into MxCAD's database and rendering process.
Usage:
- Inherit McDbCustomEntity and implement getTypeName() and creat();
- Synchronize custom attributes in dwgInFields()/dwgOutFields();
- Use MxCADWorldDraw in worldDraw() to complete the drawing;
- If editing is required, rewrite methods such as moveGripPointsAt() and getGripPoints();
- Use rxInit() to register custom entities, and then create objects through commands.
Summary: McDbCCustoms Entity is the core abstract class for MxCAD custom entity development, responsible for encapsulating the geometry, properties, and rendering behavior of objects together, making it convenient for developers to extend CAD functionality.
Example
import { IMcDbDwgFiler, McDbCustomEntity, McDbEntity, McDbLine, McGeMatrix3d, McGePoint3d, McGePoint3dArray, MxCADUiPrPoint, MxCADWorldDraw, MxCpp } from "mxcad";
class McDbTestLine extends McDbCustomEntity {
private pt1: McGePoint3d = new McGePoint3d();
private pt2: McGePoint3d = new McGePoint3d();
private matrix: McGeMatrix3d = new McGeMatrix3d()
constructor(imp?: any) {
super(imp);
}
public create(imp: any) {
return new McDbTestLine(imp)
}
public getTypeName(): string {
return "McDbTestLine";
}
public dwgInFields(filter: IMcDbDwgFiler): boolean {
this.pt1 = filter.readPoint("pt1").val;
this.pt2 = filter.readPoint("pt2").val;
const matrixStr = filter.readString("matrix").val;
const matrixData = JSON.parse(matrixStr) as number[][];
//Reconstruct matrix data
for (let i = 0; i < matrixData.length; i++) {
for (let j = 0; j < matrixData[i].length; j++) {
this.matrix.setData(i, j, matrixData[i][j]);
}
}
return true;
}
public dwgOutFields(filter: IMcDbDwgFiler): boolean {
filter.writePoint("pt1", this.pt1);
filter.writePoint("pt2", this.pt2);
const matrix: number[][] = [];
for (let i = 0; i < 4; i++) {
matrix[i] = [];
for (let j = 0; j < 4; j++) {
matrix[i][j] = this.matrix.getData(i, j);
}
}
filter.writeString("matrix", JSON.stringify(matrix));
return true;
}
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;
}
};
public getGripPoints(): McGePoint3dArray {
let ret = new McGePoint3dArray()
ret.append(this.pt1);
ret.append(this.pt2);
return ret;
};
public worldDraw(draw: MxCADWorldDraw): void {
let tmpline = new McDbLine(this.pt1, this.pt2);
tmpline.transformBy(this.matrix)
draw.drawEntity(tmpline);
}
public setPoint1(pt1: McGePoint3d) {
this.assertWrite();
this.pt1 = pt1.clone();
}
public setPoint2(pt2: McGePoint3d) {
this.assertWrite();
this.pt2 = pt2.clone();
}
public getPoint1() {
return this.pt1;
}
public getPoint2() {
return this.pt2;
};
//Edit transformations (or directly record the transformation matrix for execution in dynamic rendering)
public transformBy(mat: McGeMatrix3d): boolean {
this.matrix = this.matrix.preMultBy(mat);
this.assertWrite();
return true;
};
//Surrounding box output
public getBoundingBox(): { minPt: McGePoint3d; maxPt: McGePoint3d; ret: boolean } {
const minX = Math.min(this.pt1.x, this.pt2.x);
const minY = Math.min(this.pt1.y, this.pt2.y);
const maxX = Math.max(this.pt1.x, this.pt2.x);
const maxY = Math.max(this.pt1.y, this.pt2.y);
return {
minPt: new McGePoint3d(minX, minY, 0),
maxPt: new McGePoint3d(maxX, maxY, 0),
ret: true
};
}
}
async function MxTest_DrawCustomEntity() {
let mxcad = MxCpp.getCurrentMxCAD();
const getPoint = new MxCADUiPrPoint();
GetPoint.setMessage ("\ nSpecify a point:");
let pt1 = (await getPoint.go());
if (!pt1) return;
getPoint.setBasePt(pt1);
getPoint.setUseBasePt(true);
GetPoint.setMessage ("\ nSpecify two points:");
let pt2 = (await getPoint.go());
if (!pt2) return;
let myline = new McDbTestLine();
myline.setPoint1(pt1);
myline.setPoint2(pt2);
mxcad.drawEntity(myline);
};
//Register custom entity
new McDbTestLine().rxInit();Hierarchy
↳
McDbCustomEntity↳↳
MxCADMText↳↳
McDbMLine
Table of contents
Constructors
Properties
Accessors
- colorIndex
- drawOrder
- dxf0
- layer
- layerId
- linetype
- linetypeId
- linetypeScale
- lineweight
- normal
- objectName
- textStyle
- textStyleId
- thickness
- trueColor
- visible
Methods
- IntersectWith
- assertObjectModification
- clone
- create
- createExtensionDictionary
- deleteXData
- disableDisplay
- dwgInFields
- dwgOutFields
- erase
- explode
- getAllAppName
- getArea
- getBoundingBox
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripEditBasePointsIndex
- getGripPoints
- getHandle
- getImp
- getJson
- getName
- getObjectID
- getOwnerID
- getTypeName
- getxData
- getxDataDouble
- getxDataLong
- getxDataPoint
- getxDataString
- highlight
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- mirror
- move
- moveGripPointsAt
- rotate
- rxInit
- scaleEntity
- setJson
- setxData
- setxDataDouble
- setxDataLong
- setxDataPoint
- setxDataString
- syncData
- transformBy
- unErase
- updateDisplay
- worldDraw
Constructors
constructor
• new McDbCustomEntity(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | Any | Internal implementation object |
Overrides
Properties
imp
• imp: any = 0
Internal implementation object.
Inherited from
Accessors
colorIndex
• get colorIndex(): number
Obtain object color index
Returns
number
Inherited from
McDbEntity.colorIndex
• set colorIndex(val): void
Set object color index
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | ColorIndexType |
Returns
void
Inherited from
McDbEntity.colorIndex
drawOrder
• get drawOrder(): number
Display order of objects
Returns
number
Inherited from
McDbEntity.drawOrder
• set drawOrder(order): void
Display order of objects
Parameters
| Name | Type | Description |
|---|---|---|
| Order | number | sequential value |
Returns
void
Example
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
McDbEntity.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
McDbEntity.dxf0
layer
• get layer(): string
Obtain the layer name of the object
Returns
string
Inherited from
McDbEntity.layer
• set layer(val): void
Set object layer name
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Layer Name |
Returns
void
Inherited from
McDbEntity.layer
layerId
• get layerId(): McObjectId
Get layer ID object
Returns
Inherited from
McDbEntity.layerId
• set layerId(id): void
Set Layer Id Object
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbEntity.layerId
linetype
• get linetype(): string
Obtain the object line type name
Returns
string
Inherited from
McDbEntity.linetype
• set linetype(val): void
Set object line type name
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Line type name |
Returns
void
Inherited from
McDbEntity.linetype
linetypeId
• get linetypeId(): McObjectId
Get entity object line type ID
Returns
Inherited from
McDbEntity.linetypeId
• set linetypeId(id): void
Set entity object line type ID
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Inherited from
McDbEntity.linetypeId
linetypeScale
• get linetypeScale(): number
Obtain the proportion of object line types
Returns
number
Inherited from
McDbEntity.linetypeScale
• set linetypeScale(val): void
Set object line type scale
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | Line type ratio |
Returns
void
Inherited from
McDbEntity.linetypeScale
lineweight
• get lineweight(): number
Obtain object line weight
Returns
number
Inherited from
McDbEntity.lineweight
• set lineweight(val): void
Set object line weight
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | line weight |
Returns
void
Inherited from
McDbEntity.lineweight
normal
• get normal(): McGeVector3d
Return the normal of the object
Returns
Inherited from
McDbEntity.normal
• set normal(val): void
Set the normal of the object
Parameters
| Name | Type |
|---|---|
val | McGeVector3d |
Returns
void
Inherited from
McDbEntity.normal
objectName
• get objectName(): string
Get the object name.
Returns
string
Return object name
Inherited from
McDbEntity.objectName
textStyle
• get textStyle(): string
Obtain the text style of the object
Returns
string
Inherited from
McDbEntity.textStyle
• set textStyle(val): void
Set object text style
Parameters
| Name | Type | Description |
|---|---|---|
| Val | string | Text style name |
Returns
void
Inherited from
McDbEntity.textStyle
textStyleId
• get textStyleId(): McObjectId
Get entity text style
Returns
Inherited from
McDbEntity.textStyleId
• set textStyleId(id): void
Set the text style of the entity
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Example
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
McDbEntity.textStyleId
thickness
• get thickness(): number
Obtain the thickness of the object
Returns
number
Inherited from
McDbEntity.thickness
• set thickness(val): void
Set object thickness
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Inherited from
McDbEntity.thickness
trueColor
• get trueColor(): McCmColor
Obtain the color of the object
Returns
Inherited from
McDbEntity.trueColor
• set trueColor(val): void
Set object color
Parameters
| Name | Type |
|---|---|
val | McCmColor |
Returns
void
Inherited from
McDbEntity.trueColor
visible
• get visible(): boolean
Is the object visible
Returns
boolean
Inherited from
McDbEntity.visible
• set visible(val): void
Set whether it is visible
Parameters
| Name | Type | Description |
|---|---|---|
| Val | boolean | Boolean value |
Returns
void
Inherited from
McDbEntity.visible
Methods
IntersectWith
▸ IntersectWith(intersectObject, exOption): McGePoint3dArray
Intersection with other entities to obtain the intersection point
Parameters
| Name | Type | Description |
|---|---|---|
| IntersectObject | [McDbEntity] (2d. McDbEntity. md) | The entity object that needs to intersect is the entity object |
| ExOption | Intersection (../enums/2d. McDb. Intersect. md) | Intersection options |
Returns
Obtain all intersection points
Example
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
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 | Description |
|---|---|---|---|
| AutoUndo | boolean | false | Should this modification automatically support undo? Default is false |
Returns
number
Inherited from
McDbEntity.assertObjectModification
clone
▸ clone(): null | McDbObject
Copy entity
Returns
null | McDbObject
Overrides
create
▸ Abstract create(imp?): McDbCustomEntity
Create a new custom object (by default, call its constructor to create a new object)
Parameters
| Name | Type |
|---|---|
imp? | any |
Returns
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Returns
boolean
Inherited from
McDbEntity.createExtensionDictionary
deleteXData
▸ deleteXData(appName): boolean
Delete data related to entity specified application name
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
boolean
Example
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
disableDisplay
▸ disableDisplay(isDisable): void
Disable automatic update display of objects
Parameters
| Name | Type | Description |
|---|---|---|
| IsDisable | boolean | Do you want to disable automatic object update display |
Returns
void
Inherited from
dwgInFields
▸ Abstract dwgInFields(filter): boolean
Read custom entity data fields from DWG files
Parameters
| Name | Type |
|---|---|
filter | IMcDbDwgFiler |
Returns
boolean
dwgOutFields
▸ Abstract dwgOutFields(filter): boolean
Write the data fields of custom entities to a DWG file
Parameters
| Name | Type |
|---|---|
filter | IMcDbDwgFiler |
Returns
boolean
erase
▸ erase(): boolean
Delete object.
Returns
boolean
Whether the deletion was successful.
Inherited from
explode
▸ explode(): MxCADResbuf
Break the object and return the linked list of the object's data after being broken
Returns
Rebuf data
Example
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
getAllAppName
▸ getAllAppName(): McGeStringArray
Get the application name (AppName) of all XData records contained in the entity
Returns
Inherited from
getArea
▸ getArea(): Object
Calculate Area
Returns
Object
Is the val area value | ret successfully obtained
| Name | Type |
|---|---|
ret | boolean |
val | number |
Example
import { McGePoint3d, McDbCircle } from "mxcad"
const circle = new McDbCircle(0,0,0, 20);
const area = circle.getArea();
Console.log ("Circle area: ", area)Inherited from
getBoundingBox
▸ getBoundingBox(): Object
Obtain the minimum outsourcing of the object
Returns
Object
| Name | Type |
|---|---|
maxPt | McGePoint3d |
minPt | McGePoint3d |
ret | boolean |
Overrides
getDatabase
▸ getDatabase(): McDbDatabase
Get the database where the object is located
Returns
Return to database
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
Get the index ID of the object
Returns
number
Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
Obtain the extended dictionary data of the object
Returns
Expand dictionary data
Inherited from
McDbEntity.getExtensionDictionary
getGripEditBasePointsIndex
▸ getGripEditBasePointsIndex(): number[]
Get the grip of the custom object.
Returns
number[]
Pinch object array
Overrides
McDbEntity.getGripEditBasePointsIndex
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the grip of the custom object.
Returns
Pinch object array
Overrides
getHandle
▸ getHandle(): string
Obtain object handle
Returns
string
Return object handle
Inherited from
getImp
▸ getImp(): any
Retrieve internal implementation objects.
Returns
any
Internal implementation object.
Inherited from
getJson
▸ getJson(): string
Retrieve a string in JSON format.
Returns
string
A string in JSON format.
Inherited from
getName
▸ getName(): string
Get custom object name
Returns
string
getObjectID
▸ getObjectID(): McObjectId
Get the object ID.
Returns
Object ID.
Inherited from
getOwnerID
▸ getOwnerID(): number
Obtain the ID of the object owner
Returns
number
Inherited from
getTypeName
▸ Abstract getTypeName(): string
Get the type name of the custom entity.
Returns
string
Custom entity type name
getxData
▸ getxData(appName?): MxCADResbuf
Obtain the extended data of the object
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AppName | string | "" | Extended Data Name |
Returns
Inherited from
getxDataDouble
▸ getxDataDouble(appName): Object
Retrieve the double value from the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Double value
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getxDataLong
▸ getxDataLong(appName): Object
Retrieve the long (integer) value from the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Long value
| Name | Type |
|---|---|
ret | boolean |
val | number |
Inherited from
getxDataPoint
▸ getxDataPoint(appName): Object
Retrieve point objects from the specified XData type of entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Obtain results and 3D point objects
| Name | Type |
|---|---|
ret | boolean |
val | McGePoint3d |
Inherited from
getxDataString
▸ getxDataString(appName): Object
Retrieve XData information associated with a specific entity and return it in string form
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
Returns
Object
Val XData information | whether ret returns success
| Name | Type |
|---|---|
ret | boolean |
val | string |
Inherited from
highlight
▸ highlight(isHighlight): void
Set whether the object is highlighted
Parameters
| Name | Type | Description |
|---|---|---|
| IsHighlight | boolean | Is it highlighted |
Returns
void
Inherited from
initTempObject
▸ initTempObject(imp): void
Initialize temporary objects.
Parameters
| Name | Type | Description |
|---|---|---|
| 'imp' | 'any' | Internal implementation object |
Returns
void
Inherited from
isErased
▸ isErased(): boolean
Has the object been deleted
Returns
boolean
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
Is there any extended dictionary data available
Returns
boolean
Inherited from
McDbEntity.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
Inherited from
isNull
▸ isNull(): any
Determine if it is an empty object
Returns
any
Inherited from
mirror
▸ mirror(point1, point2): boolean
Mirror oriented object
Parameters
| Name | Type | Description |
|---|---|---|
| Point1 | [McGePoint3d] (2d. McGePoint3d. md) | Mirror Base Point |
point2 | McGePoint3d | - |
Returns
boolean
Inherited from
move
▸ move(fromPoint, toPoint): boolean
move objects
Parameters
| Name | Type | Description |
|---|---|---|
| From Point | [McGePoint3d] (2d. McGePoint3d. md) | Move the starting point |
| ToPoint | [McGePoint3d] (2d. McGePoint3d. md) | Move End Point |
Returns
boolean
Inherited from
moveGripPointsAt
▸ moveGripPointsAt(_iIndex, _dXOffset, _dYOffset, _dZOffset): void
Move the grip of custom objects.
Parameters
| Name | Type | Description |
|---|---|---|
_iIndex | number | Grip Index |
d_XOffset | number | X-axis offset |
| 3dYOffset | number | Y-axis offset |
| 3dZOffset | number | Z-axis offset |
Returns
void
Example
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
rotate
▸ rotate(basePoint, dRotationAngle): boolean
Rotate object
Parameters
| Name | Type | Description |
|---|---|---|
| BasePoint | [McGePoint3d] (2d. McGePoint3d. md) | Rotate the base point |
| DRotationAngle | number | Rotation angle |
Returns
boolean
Inherited from
rxInit
▸ rxInit(): void
Custom Entity Registration
Returns
void
Example
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
})scaleEntity
▸ scaleEntity(basePoint, dScaleFactor): boolean
Scaling objects
Parameters
| Name | Type | Description |
|---|---|---|
| BasePoint | [McGePoint3d] (2d. McGePoint3d. md) | Scale Base Point |
| DScaleFactor | number | scaling factor (<1 zoom out;>1 zoom in) |
Returns
boolean
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.
Inherited from
setxData
▸ setxData(xdata): boolean
Set extended data for objects
Parameters
| Name | Type | Description |
|---|---|---|
| Xdata | [MxCADResbuf] (2d. MxCADResbuf. md) | Extended data linked list |
Returns
boolean
Example
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
setxDataDouble
▸ setxDataDouble(appName, val): boolean
Set the double value in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | double value |
Returns
boolean
Boolean value
Example
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
setxDataLong
▸ setxDataLong(appName, val): boolean
Set the long (integer) value in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | number | long value |
Returns
boolean
Long value
Example
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
setxDataPoint
▸ setxDataPoint(appName, val): boolean
Set the point object in the specified XData type of the entity
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | [McGePoint3d] (2d. McGePoint3d. md) | Point Object |
Returns
boolean
Obtain results and 3D point objects
Inherited from
setxDataString
▸ setxDataString(appName, val): boolean
Set XData information associated with a specific entity and set it in string form
Parameters
| Name | Type | Description |
|---|---|---|
| AppName | string | Extended Data Name |
| Val | string | string value |
Returns
boolean
Is the setting successful
Inherited from
syncData
▸ syncData(toCpp?): boolean
JS object data and McDbCCustoms Entity: Synchronization of m_mapData.
Parameters
| Name | Type | Default value |
|---|---|---|
toCpp | boolean | true |
Returns
boolean
Overrides
transformBy
▸ transformBy(_mat): boolean
Get custom object matrix coordinate transformation
Parameters
| Name | Type |
|---|---|
_mat | McGeMatrix3d |
Returns
boolean
Overrides
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
Inherited from
updateDisplay
▸ updateDisplay(): void
Display the updated display of the calling object
Returns
void
Inherited from
worldDraw
▸ Abstract worldDraw(draw): void
Draw custom entities
Parameters
| Name | Type |
|---|---|
draw | MxCADWorldDraw |
Returns
void
