[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/MxCADMText
Class: MxCADMText
2d.MxCADMText
Custom Editor Entity Class Used for rendering and managing rich text editors in CAD
Hierarchy
↳
MxCADMText
Table of contents
Constructors
Properties
- convertCadPointToSlatePoint
- convertSlatePointToCadPoint
- imp
- transformBy
- elementTextManager
- fromMText
- toMText
Accessors
- angle
- colorIndex
- data
- drawOrder
- dxf0
- isWordWrap
- layer
- layerId
- lineHeightRatio
- linetype
- linetypeId
- linetypeScale
- lineweight
- maxHeight
- maxWidth
- normal
- objectName
- position
- textAlignment
- textBaseHeight
- textStyle
- textStyleId
- trueColor
- visible
Methods
- IntersectWith
- assertObjectModification
- clone
- create
- createExtensionDictionary
- deleteXData
- disableDisplay
- dwgInFields
- dwgOutFields
- erase
- explode
- getAllAppName
- getArea
- getBoundingBox
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripPoints
- getHandle
- getImp
- getJson
- getMTextImp
- 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
- unErase
- updateDisplay
- worldDraw
Constructors
constructor
• new MxCADMText(imp?)
Parameters
| Name | Type |
|---|---|
imp? | any |
Overrides
Properties
convertCadPointToSlatePoint
• convertCadPointToSlatePoint: (this: MxCADMText, point: McGePoint3d) => { offset: number ; path: number[] } | null = convertCadPointToSlatePoint
Type declaration
▸ (this, point): { offset: number ; path: number[] } | null
Convert CAD coordinates to Slate's Point position
Parameters
| Name | Type |
|---|---|
this | MxCADMText |
point | McGePoint3d |
Returns
{ offset: number ; path: number[] } | null
convertSlatePointToCadPoint
• convertSlatePointToCadPoint: (this: MxCADMText, point: IMxEditorPoint) => { lineIndex: number ; point: McGePoint3d } | null = convertSlatePointToCadPoint
Type declaration
▸ (this, point): { lineIndex: number ; point: McGePoint3d } | null
Convert Slate's Point position to CAD coordinates
Parameters
| Name | Type |
|---|---|
this | MxCADMText |
point | IMxEditorPoint |
Returns
{ lineIndex: number ; point: McGePoint3d } | null
imp
• imp: any = 0
Internal implementation object.
Inherited from
transformBy
• transformBy: (this: MxCADMText, mat: McGeMatrix3d) => boolean = transformBy
Type declaration
▸ (this, mat): boolean
Application of Matrix Transformation
Parameters
| Name | Type |
|---|---|
this | MxCADMText |
mat | McGeMatrix3d |
Returns
boolean
Overrides
elementTextManager
▪ Static elementTextManager: ElementTextManager
fromMText
▪ Static fromMText: (mtext: McDbMText) => MxCADMText = MultilineTextConverter.fromMText
Type declaration
▸ (mtext): MxCADMText
Convert McDbMText to MxCADMText
Parameters
| Name | Type |
|---|---|
mtext | McDbMText |
Returns
toMText
▪ Static toMText: (customEntity: MxCADMText, mtext?: McDbMText) => (McDbEntity | McDbCustomEntity)[] = MultilineTextConverter.toMText
Type declaration
▸ (customEntity, mtext?): (McDbEntity | McDbCustomEntity)[]
Convert MxCADMText to McDBMText
Parameters
| Name | Type |
|---|---|
customEntity | MxCADMText |
mtext? | McDbMText |
Returns
(McDbEntity | McDbCustomEntity)[]
Accessors
angle
• get angle(): number
Returns
number
• set angle(angle): void
Parameters
| Name | Type |
|---|---|
angle | number |
Returns
void
colorIndex
• get colorIndex(): number
Obtain object color index
Returns
number
Example
import { McDbEntity, ColorIndexType } from 'mxcad'
const ent = new McDbEntity();
ent.colorIndex = ColorIndexType.kByblock;
console.log(ent.colorIndex)Inherited from
McDbCustomEntity.colorIndex
• set colorIndex(val): void
Set object color index
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | ColorIndexType |
Returns
void
Inherited from
McDbCustomEntity.colorIndex
data
• get data(): IMxEditorDescendant[]
Returns
IMxEditorDescendant[]
• set data(val): void
Parameters
| Name | Type |
|---|---|
val | IMxEditorDescendant[] |
Returns
void
drawOrder
• get drawOrder(): number
Display order of objects
Returns
number
Example
//Assuming ent is a valid instance object
const order = ent.drawOrder();Inherited from
McDbCustomEntity.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
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 a line is McDbLine, and the DXF0 group code value is LINE. The DXF0 group code value can be used for type filtering when constructing sets.
Returns
string
Inherited from
McDbCustomEntity.dxf0
isWordWrap
• get isWordWrap(): boolean
Returns
boolean
• set isWordWrap(value): void
Set auto wrap
Parameters
| Name | Type |
|---|---|
value | boolean |
Returns
void
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
| Name | Type | Description |
|---|---|---|
| Val | string | Layer Name |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity();
ent.layer = "newLayerName";
console.log(ent.layer)Inherited from
McDbCustomEntity.layer
layerId
• get layerId(): McObjectId
Get layer ID object
Returns
Example
//Assuming ent is a valid instance object
const layerId = ent.layerId;Inherited from
McDbCustomEntity.layerId
• set layerId(id): void
Set Layer Id Object
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
Const layerId=mxcad. addLayer (Test Layer)
ent.layerId = layerId;Inherited from
McDbCustomEntity.layerId
lineHeightRatio
• get lineHeightRatio(): number
Returns
number
• set lineHeightRatio(ratio): void
Parameters
| Name | Type |
|---|---|
ratio | number |
Returns
void
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
| Name | Type | Description |
|---|---|---|
| Val | string | Line type name |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetype = "MyLineType";
console.log(ent.linetype)Inherited from
McDbCustomEntity.linetype
linetypeId
• get linetypeId(): McObjectId
Get entity object line type ID
Returns
Example
//Assuming ent is a valid instance object
const linetypeId = ent.linetypeId;Inherited from
McDbCustomEntity.linetypeId
• set linetypeId(id): void
Set entity object line type ID
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;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
| Name | Type | Description |
|---|---|---|
| Val | number | Line type ratio |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetypeScale = 0.8;
console.log(ent.linetypeScale)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
| Name | Type | Description |
|---|---|---|
| Val | number | line weight |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.lineweight = 20;
console.log(ent.lineweight)Inherited from
McDbCustomEntity.lineweight
maxHeight
• get maxHeight(): number
Returns
number
• set maxHeight(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
maxWidth
• get maxWidth(): number
Returns
number
• set maxWidth(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
normal
• get normal(): McGeVector3d
Return the normal of the object
Returns
Example
Inherited from
McDbCustomEntity.normal
• set normal(val): void
Set the normal of the object
Parameters
| Name | Type |
|---|---|
val | McGeVector3d |
Returns
void
Example
Inherited from
McDbCustomEntity.normal
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
McDbCustomEntity.objectName
position
• get position(): McGePoint3d
Returns
• set position(val): void
Parameters
| Name | Type |
|---|---|
val | McGePoint3d |
Returns
void
textAlignment
• get textAlignment(): AttachmentPoint
Returns
• set textAlignment(alignment): void
Parameters
| Name | Type |
|---|---|
alignment | AttachmentPoint |
Returns
void
textBaseHeight
• get textBaseHeight(): number
Returns
number
• set textBaseHeight(val): void
Parameters
| Name | Type |
|---|---|
val | number |
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
| Name | Type | Description |
|---|---|---|
| Val | string | Text style name |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.textStyle = "st_style";Inherited from
McDbCustomEntity.textStyle
textStyleId
• get textStyleId(): McObjectId
Get entity text style
Returns
Example
//Assuming ent is a valid instance object
const textStyleId = ent.textStyleId;Inherited from
McDbCustomEntity.textStyleId
• set textStyleId(id): void
Set the text style of the entity
Parameters
| Name | Type |
|---|---|
id | McObjectId |
Returns
void
Example
//Assuming ent is a valid instance object
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;Inherited from
McDbCustomEntity.textStyleId
trueColor
• get trueColor(): McCmColor
Obtain the color of the object
Returns
Example
import { McDbEntity, McCmColor} from 'mxcad'
const ent = new McDbEntity();
ent.trueColor = new McCmColor(255, 0, 0);
console.log(ent.trueColor)Inherited from
McDbCustomEntity.trueColor
• set trueColor(val): void
Set object color
Parameters
| Name | Type |
|---|---|
val | McCmColor |
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
| Name | Type | Description |
|---|---|---|
| Val | boolean | Boolean value |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.visible = true;
console.log(ent.visible)Inherited from
McDbCustomEntity.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
McDbCustomEntity.IntersectWith
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
McDbCustomEntity.assertObjectModification
clone
▸ clone(): null | McDbObject
Copy entity
Returns
null | McDbObject
Example
import { McDbCustomEntity } from "mxcad";
const customEnt = new McDbCustomEntity(); //Construct a new custom entity object
const cloneEnt = customEnt.clone(); //Copy entityInherited from
create
▸ create(imp): MxCADMText
Create a new custom object (by default, call its constructor to create a new object)
Parameters
| Name | Type |
|---|---|
imp | any |
Returns
Overrides
createExtensionDictionary
▸ createExtensionDictionary(): boolean
Create extended dictionary data for objects
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.createExtensionDictionary();Inherited from
McDbCustomEntity.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
Example
import { McDbLine } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
line1.disableDisplay(true)Inherited from
McDbCustomEntity.disableDisplay
dwgInFields
▸ dwgInFields(filter): boolean
Read custom entity data fields from DWG files
Parameters
| Name | Type |
|---|---|
filter | IMcDbDwgFiler |
Returns
boolean
Example
import { McDbCustomEntity, IMcDbDwgFiler } from 'mxcad'
//Create a new McDbTestLineCustomizing Entity class to inherit McDbCustomizing Entity
class McDbTestLineCustomEntity extends McDbCustomEntity {
//Define the point objects pt1 and pt2 inside the McDbtTestLineCustomizing Entity
private pt1: McGePoint3d = new McGePoint3d();
private pt2: McGePoint3d = new McGePoint3d();
//Read the data fields pt1 and pt2 of custom entities
public dwgInFields(filter: IMcDbDwgFiler): boolean {
this.pt1 = filter.readPoint("pt1").val;
this.pt2 = filter.readPoint("pt2").val;
return true;
}
}Overrides
dwgOutFields
▸ dwgOutFields(filter): boolean
Write the data fields of custom entities to a DWG file
Parameters
| Name | Type |
|---|---|
filter | IMcDbDwgFiler |
Returns
boolean
Example
//Create a new McDbTestLineCustomizing Entity class to inherit McDbCustomizing Entity
import { McDbCustomEntity, IMcDbDwgFiler } from 'mxcad'
class McDbTestLineCustomEntity extends McDbCustomEntity {
//Define the point objects pt1 and pt2 inside the McDbtTestLineCustomizing Entity
private pt1: McGePoint3d = new McGePoint3d();
private pt2: McGePoint3d = new McGePoint3d();
//Write data fields pt1 and pt2 for custom entities
public dwgOutFields(filter: IMcDbDwgFiler): boolean {
filter.writePoint("pt1", this.pt1);
filter.writePoint("pt2", this.pt2);
return true;
}
}Overrides
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
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 smash:");
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
Example
//Assuming ent is a valid instance object
const appNames = ent.getAllAppName();
console.log(appNames);Inherited from
McDbCustomEntity.getAllAppName
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 |
Inherited from
McDbCustomEntity.getBoundingBox
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
McDbCustomEntity.getDatabaseIndexId
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
McDbCustomEntity.getExtensionDictionary
getGripPoints
▸ getGripPoints(): McGePoint3dArray
Get the grip of the custom object.
Returns
Pinch object array
Overrides
McDbCustomEntity.getGripPoints
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
getMTextImp
▸ getMTextImp(): MxCADMTextImp
Returns
MxCADMTextImp
getName
▸ getName(): string
Get custom object name
Returns
string
Overrides
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
getTypeName
▸ getTypeName(): string
Get the type name of the custom entity.
Returns
string
Custom entity type name
Overrides
getxData
▸ getxData(appName?): MxCADResbuf
Obtain the extended data of the object
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AppName | string | "" | Extended Data Name |
Returns
Example
//Assuming ent is a valid instance object
const xData = ent.getXData();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 |
Example
//Assuming ent is a valid instance object
let data = ent.getxDataDouble("DataName");
if(data.ret){
console.log(data.val)
}Inherited from
McDbCustomEntity.getxDataDouble
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 |
Example
//Assuming ent is a valid instance object
let data = ent.getxDataLong("DataName");
if(data.ret){
console.log(data.val)
}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
McDbCustomEntity.getxDataPoint
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 |
Example
//Assuming ent is a valid instance object
let data = ent.getxDataString("DataName");
if(data.ret){
console.log(data.val)
}Inherited from
McDbCustomEntity.getxDataString
highlight
▸ highlight(isHighlight): void
Set whether the object is highlighted
Parameters
| Name | Type | Description |
|---|---|---|
| IsHighlight | boolean | Is it highlighted |
Returns
void
Example
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.highlight(true);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
McDbCustomEntity.initTempObject
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
McDbCustomEntity.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 falseInherited 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 falseInherited 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
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.mirror(new McGePoint3d(0,0,0), new McGePoint3d(20,10,0))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
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.move(new McGePoint3d(0,0,0), new McGePoint3d(20,0,0))Inherited from
moveGripPointsAt
▸ moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): void
Move the grip of custom objects.
Parameters
| Name | Type | Description |
|---|---|---|
| IIndex | Number | Grip Index |
| DXOffset | number | X-axis offset |
| DYOffset | number | Y-axis offset |
| DZOffset | 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 objects pt1 and pt2 inside the McDbtTestLineCustomizing Entity
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
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
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.rotate(new McGePoint3d(0,0,0), Math.PI)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
})Inherited from
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
Example
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.scaleEntity(new McGePoint3d(0,0,0), 0.5)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
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
McDbCustomEntity.setxDataDouble
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
McDbCustomEntity.setxDataPoint
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
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.setxDataString("DataName", "xxxxx");
if(res){
//Setting successful
}else{
//Setting failed
}Inherited from
McDbCustomEntity.setxDataString
syncData
▸ syncData(toCpp?): boolean
Synchronization of JS object data with McDbCCustoms Entity:: m_mapData.
Parameters
| Name | Type | Default value |
|---|---|---|
toCpp | boolean | true |
Returns
boolean
Inherited from
unErase
▸ unErase(): boolean
Anti delete object.
Returns
boolean
Example
//Assuming obj is a database object
const res = obj.unErase();
console.log(res);Inherited from
updateDisplay
▸ updateDisplay(): void
Display the updated display of the calling object
Returns
void
Example
//Assuming ent is a valid instance object
ent.updateDisplay()Inherited from
McDbCustomEntity.updateDisplay
worldDraw
▸ worldDraw(draw): void
Draw custom entities
Parameters
| Name | Type |
|---|---|
draw | MxCADWorldDraw |
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 objects pt1 and pt2 inside the McDbtTestLineCustomizing Entity
private pt1: McGePoint3d = new McGePoint3d();
private pt2: McGePoint3d = new McGePoint3d();
//Draw entities
public worldDraw(draw: MxCADWorldDraw): void {
let tmpline = new McDbLine(this.pt1, this.pt2);
draw.drawEntity(tmpline);
}
}