Skip to content

mxcad_2d API 文档 / 2d / MxCADMText

Class: MxCADMText ​

2d.MxCADMText

自定义编辑器实体类 用于在CAD中渲染和管理富文本编辑器

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new MxCADMText(imp?)

Parameters ​

NameType
imp?any

Overrides ​

McDbCustomEntity.constructor

Properties ​

convertCadPointToSlatePoint ​

• convertCadPointToSlatePoint: (this: MxCADMText, point: McGePoint3d) => { offset: number ; path: number[] } | null = convertCadPointToSlatePoint

Type declaration ​

▸ (this, point): { offset: number ; path: number[] } | null

CAD坐标转换为Slate的Point位置

Parameters ​
NameType
thisMxCADMText
pointMcGePoint3d
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

Slate的Point位置转换为CAD坐标

Parameters ​
NameType
thisMxCADMText
pointIMxEditorPoint
Returns ​

{ lineIndex: number ; point: McGePoint3d } | null


imp ​

• imp: any = 0

内部实现对象。

Inherited from ​

McDbCustomEntity.imp


transformBy ​

• transformBy: (this: MxCADMText, mat: McGeMatrix3d) => boolean = transformBy

Type declaration ​

▸ (this, mat): boolean

矩阵变换应用

Parameters ​
NameType
thisMxCADMText
matMcGeMatrix3d
Returns ​

boolean

Overrides ​

McDbCustomEntity.transformBy


elementTextManager ​

▪ Static elementTextManager: ElementTextManager


fromMText ​

▪ Static fromMText: (mtext: McDbMText) => MxCADMText = MultilineTextConverter.fromMText

Type declaration ​

▸ (mtext): MxCADMText

从McDbMText转换为MxCADMText

Parameters ​
NameType
mtextMcDbMText
Returns ​

MxCADMText


toMText ​

▪ Static toMText: (customEntity: MxCADMText, mtext?: McDbMText) => (McDbEntity | McDbCustomEntity)[] = MultilineTextConverter.toMText

Type declaration ​

▸ (customEntity, mtext?): (McDbEntity | McDbCustomEntity)[]

从MxCADMText转换为McDbMText

Parameters ​
NameType
customEntityMxCADMText
mtext?McDbMText
Returns ​

(McDbEntity | McDbCustomEntity)[]

Accessors ​

angle ​

• get angle(): number

Returns ​

number

• set angle(angle): void

Parameters ​

NameType
anglenumber

Returns ​

void


colorIndex ​

• get colorIndex(): number

得到对象颜色索引

Example

ts
 import { McDbEntity, ColorIndexType } from 'mxcad'
 const ent = new McDbEntity();
 ent.colorIndex = ColorIndexType.kByblock;
 console.log(ent.colorIndex)

Returns ​

number

Inherited from ​

McDbCustomEntity.colorIndex

• set colorIndex(val): void

设置对象颜色索引

Parameters ​

NameTypeDescription
valnumber颜色索引(ColorIndexType)

Returns ​

void

Inherited from ​

McDbCustomEntity.colorIndex


data ​

• get data(): IMxEditorDescendant[]

Returns ​

IMxEditorDescendant[]

• set data(val): void

Parameters ​

NameType
valIMxEditorDescendant[]

Returns ​

void


drawOrder ​

• get drawOrder(): number

对象的显示顺序

Example

ts
// 假设ent为有效实例对象
const order = ent.drawOrder();

Returns ​

number

Inherited from ​

McDbCustomEntity.drawOrder

• set drawOrder(order): void

对象的显示顺序

Example

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

let ss = new MxCADSelectionSet();
if (!await ss.userSelect("\n选择对象")) return;
//得到当前图上对象的最大,小最显示顺序.
let minmaxOrder = MxCpp.getCurrentDatabase().currentSpace.getMinMaxDrawOrder();
// 把对象放到最上面。
let lOrder = minmaxOrder.maxDrawOrder + 1;
ss.forEach((id) => {
  let ent = id.getMcDbEntity();
  if (ent) {
    ent.drawOrder = lOrder;
  }
})

Parameters ​

NameTypeDescription
ordernumber顺序值

Returns ​

void

Inherited from ​

McDbCustomEntity.drawOrder


dxf0 ​

• get dxf0(): string

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

Returns ​

string

Inherited from ​

McDbCustomEntity.dxf0


isWordWrap ​

• get isWordWrap(): boolean

Returns ​

boolean

• set isWordWrap(value): void

设置自动换行

Parameters ​

NameType
valueboolean

Returns ​

void


layer ​

• get layer(): string

得到对象图层名

Returns ​

string

Inherited from ​

McDbCustomEntity.layer

• set layer(val): void

设置对象图层名

Example

ts
 import { McDbEntity } from 'mxcad'
 const ent = new McDbEntity();
 ent.layer = "newLayerName";
 console.log(ent.layer)

Parameters ​

NameTypeDescription
valstring图层名

Returns ​

void

Inherited from ​

McDbCustomEntity.layer


layerId ​

• get layerId(): McObjectId

获取图层ID对象

Example

ts
// 假设ent为有效实例对象
const layerId = ent.layerId;

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.layerId

• set layerId(id): void

设置图层Id对象

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const layerId = mxcad.addLayer("测试图层")
ent.layerId = layerId;

Parameters ​

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCustomEntity.layerId


lineHeightRatio ​

• get lineHeightRatio(): number

Returns ​

number

• set lineHeightRatio(ratio): void

Parameters ​

NameType
rationumber

Returns ​

void


linetype ​

• get linetype(): string

得到对象线型名

Returns ​

string

Inherited from ​

McDbCustomEntity.linetype

• set linetype(val): void

设置对象线型名

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetype = "MyLineType";
console.log(ent.linetype)

Parameters ​

NameTypeDescription
valstring线型名

Returns ​

void

Inherited from ​

McDbCustomEntity.linetype


linetypeId ​

• get linetypeId(): McObjectId

获取实体对象线型ID

Example

ts
// 假设ent为有效实例对象
const linetypeId = ent.linetypeId;

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.linetypeId

• set linetypeId(id): void

设置实体对象线型ID

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const lineId = mxcad.addLinetypeEx("TestMyLine", '25,-5');
ent.linetypeId = lineId;

Parameters ​

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCustomEntity.linetypeId


linetypeScale ​

• get linetypeScale(): number

得到对象线型比例

Returns ​

number

Inherited from ​

McDbCustomEntity.linetypeScale

• set linetypeScale(val): void

设置对象线型比例

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.linetypeScale = 0.8;
console.log(ent.linetypeScale)

Parameters ​

NameTypeDescription
valnumber线型比例

Returns ​

void

Inherited from ​

McDbCustomEntity.linetypeScale


lineweight ​

• get lineweight(): number

得到对象线重

Returns ​

number

Inherited from ​

McDbCustomEntity.lineweight

• set lineweight(val): void

设置对象线重

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.lineweight = 20;
console.log(ent.lineweight)

Parameters ​

NameTypeDescription
valnumber线重

Returns ​

void

Inherited from ​

McDbCustomEntity.lineweight


maxHeight ​

• get maxHeight(): number

Returns ​

number

• set maxHeight(val): void

Parameters ​

NameType
valnumber

Returns ​

void


maxWidth ​

• get maxWidth(): number

Returns ​

number

• set maxWidth(val): void

Parameters ​

NameType
valnumber

Returns ​

void


normal ​

• get normal(): McGeVector3d

返回对象的normal

Example

ts

Returns ​

McGeVector3d

Inherited from ​

McDbCustomEntity.normal

• set normal(val): void

设置对象的normal

Example

ts

Parameters ​

NameType
valMcGeVector3d

Returns ​

void

Inherited from ​

McDbCustomEntity.normal


objectName ​

• get objectName(): string

获取对象名称。

Example

ts
import { McRxObject } from 'mxcad';

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

Returns ​

string

返回对象名

Inherited from ​

McDbCustomEntity.objectName


position ​

• get position(): McGePoint3d

Returns ​

McGePoint3d

• set position(val): void

Parameters ​

NameType
valMcGePoint3d

Returns ​

void


textAlignment ​

• get textAlignment(): AttachmentPoint

Returns ​

AttachmentPoint

• set textAlignment(alignment): void

Parameters ​

NameType
alignmentAttachmentPoint

Returns ​

void


textBaseHeight ​

• get textBaseHeight(): number

Returns ​

number

• set textBaseHeight(val): void

Parameters ​

NameType
valnumber

Returns ​

void


textStyle ​

• get textStyle(): string

得到对象文字样式

Returns ​

string

Inherited from ​

McDbCustomEntity.textStyle

• set textStyle(val): void

设置对象文字样式

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.textStyle = "st_style";

Parameters ​

NameTypeDescription
valstring文字样式名

Returns ​

void

Inherited from ​

McDbCustomEntity.textStyle


textStyleId ​

• get textStyleId(): McObjectId

获取实体文字样式

Example

ts
// 假设ent为有效实例对象
const textStyleId = ent.textStyleId;

Returns ​

McObjectId

Inherited from ​

McDbCustomEntity.textStyleId

• set textStyleId(id): void

设置实体的文字样式

Example

ts
// 假设ent为有效实例对象
const mxcad = MxCpp.getCurrentMxCAD();
const textStyleId = mxcad.addTextStyle("MyLineTypeTextStyle", "txt.shx", "hztxt.shx", 1);
ent.textStyleId = textStyleId;

Parameters ​

NameType
idMcObjectId

Returns ​

void

Inherited from ​

McDbCustomEntity.textStyleId


trueColor ​

• get trueColor(): McCmColor

得到对象颜色

Example

ts
 import { McDbEntity, McCmColor} from 'mxcad'
 const ent = new McDbEntity();
 ent.trueColor = new McCmColor(255, 0, 0);
 console.log(ent.trueColor)

Returns ​

McCmColor

Inherited from ​

McDbCustomEntity.trueColor

• set trueColor(val): void

设置对象颜色

Parameters ​

NameType
valMcCmColor

Returns ​

void

Inherited from ​

McDbCustomEntity.trueColor


visible ​

• get visible(): boolean

对象是否可见

Returns ​

boolean

Inherited from ​

McDbCustomEntity.visible

• set visible(val): void

设置是否可见

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.visible = true;
console.log(ent.visible)

Parameters ​

NameTypeDescription
valboolean布尔值

Returns ​

void

Inherited from ​

McDbCustomEntity.visible

Methods ​

IntersectWith ​

▸ IntersectWith(intersectObject, exOption): McGePoint3dArray

与其他实体相交, 得到交点

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)

Parameters ​

NameTypeDescription
intersectObjectMcDbEntity需要相交的是实体对象
exOptionIntersect相交的选项

Returns ​

McGePoint3dArray

得到所有交点

Inherited from ​

McDbCustomEntity.IntersectWith


assertObjectModification ​

▸ assertObjectModification(autoUndo?): number

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

Example

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

Parameters ​

NameTypeDefault value
autoUndobooleanfalse

Returns ​

number

Inherited from ​

McDbCustomEntity.assertObjectModification


clone ​

▸ clone(): null | McDbObject

复制实体

Example

ts
import { McDbCustomEntity } from "mxcad";

const customEnt = new McDbCustomEntity();// 构造新自定义实体对象
const cloneEnt = customEnt.clone();// 复制实体

Returns ​

null | McDbObject

Inherited from ​

McDbCustomEntity.clone


create ​

▸ create(imp): MxCADMText

新创建一个自定义对象 (默认调用该对象的构造函数来创建新的对象)

Parameters ​

NameType
impany

Returns ​

MxCADMText

Overrides ​

McDbCustomEntity.create


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

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

Example

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

Returns ​

boolean

Inherited from ​

McDbCustomEntity.createExtensionDictionary


deleteXData ​

▸ deleteXData(appName): boolean

删除实体指定应用程序名称相关的数据

Example

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

let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
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){
  //删除成功
}else
  //删除失败
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称

Returns ​

boolean

Inherited from ​

McDbCustomEntity.deleteXData


disableDisplay ​

▸ disableDisplay(isDisable): void

禁用对象的自动更新显示.

Example

ts
import { McDbLine } from 'mxcad'
const line1 = new McDbLine(new McGePoint3d(0,0,0), new McGePoint3d(20,1,0));
line1.disableDisplay(true)

Parameters ​

NameTypeDescription
isDisableboolean是否禁用对象自动更新显示

Returns ​

void

Inherited from ​

McDbCustomEntity.disableDisplay


dwgInFields ​

▸ dwgInFields(filter): boolean

从 DWG 文件中读取自定义实体的数据字段

Example

ts
 import { McDbCustomEntity, IMcDbDwgFiler } from 'mxcad'
 // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity
 class McDbTestLineCustomEntity extends McDbCustomEntity {
   // 定义McDbTestLineCustomEntity内部的点对象 pt1、pt2
   private pt1: McGePoint3d = new McGePoint3d();
   private pt2: McGePoint3d = new McGePoint3d(); 
   // 读取自定义实体的数据字段pt1、pt2
   public dwgInFields(filter: IMcDbDwgFiler): boolean {
   this.pt1 = filter.readPoint("pt1").val;
   this.pt2 = filter.readPoint("pt2").val;
   return true;
   }
 }

Parameters ​

NameType
filterIMcDbDwgFiler

Returns ​

boolean

Overrides ​

McDbCustomEntity.dwgInFields


dwgOutFields ​

▸ dwgOutFields(filter): boolean

将自定义实体的数据字段写入到 DWG 文件中

Example

ts
 // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity
 import { McDbCustomEntity, IMcDbDwgFiler } from 'mxcad'
 class McDbTestLineCustomEntity extends McDbCustomEntity {
   // 定义McDbTestLineCustomEntity内部的点对象 pt1、pt2
   private pt1: McGePoint3d = new McGePoint3d();
   private pt2: McGePoint3d = new McGePoint3d();
   // 写入自定义实体的数据字段pt1、pt2
   public dwgOutFields(filter: IMcDbDwgFiler): boolean {
       filter.writePoint("pt1", this.pt1);
       filter.writePoint("pt2", this.pt2);
       return true;
   }
   }

Parameters ​

NameType
filterIMcDbDwgFiler

Returns ​

boolean

Overrides ​

McDbCustomEntity.dwgOutFields


erase ​

▸ erase(): boolean

删除对象。

Example

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

Returns ​

boolean

是否删除成功。

Inherited from ​

McDbCustomEntity.erase


explode ​

▸ explode(): MxCADResbuf

打碎对象,返回打后对象数据链表

Example

ts
import { McDbEntity, MxCADResbuf } from "mxcad";
// 获取目标对象
let getEnt = new MxCADUiPrEntity();
getEnt.setMessage("选择打碎对象:");
let id = await getEnt.go();
let ent:McDbEntity = id.getMcDbEntity();
if (ent === null) return;
// 打碎对象
      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);
          }
      }

Returns ​

MxCADResbuf

resbuf 数据

Inherited from ​

McDbCustomEntity.explode


getAllAppName ​

▸ getAllAppName(): McGeStringArray

获取实体中包含的所有 XData 记录的应用程序名(AppName)

Example

ts
// 假设ent为有效实例对象
const appNames = ent.getAllAppName();
console.log(appNames);

Returns ​

McGeStringArray

Inherited from ​

McDbCustomEntity.getAllAppName


getArea ​

▸ getArea(): Object

计算面积

Example

ts
import { McGePoint3d, McDbCircle } from "mxcad"

const circle = new McDbCircle(0,0,0, 20);
const area = circle.getArea();
console.log("圆面积:", area)

Returns ​

Object

val 面积值 | ret 是否获取成功

NameType
retboolean
valnumber

Inherited from ​

McDbCustomEntity.getArea


getBoundingBox ​

▸ getBoundingBox(): Object

得到对象的最小外包

Returns ​

Object

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Inherited from ​

McDbCustomEntity.getBoundingBox


getDatabase ​

▸ getDatabase(): McDbDatabase

得到对象所在的数据库

Example

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

Returns ​

McDbDatabase

返回数据库

Inherited from ​

McDbCustomEntity.getDatabase


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

获取对象的索引ID

Example

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

Returns ​

number

Inherited from ​

McDbCustomEntity.getDatabaseIndexId


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

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

Example

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

Returns ​

McDbDictionary

扩展字典数据

Inherited from ​

McDbCustomEntity.getExtensionDictionary


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

获取自定义对象的夹点。

Returns ​

McGePoint3dArray

夹点对象数组

Overrides ​

McDbCustomEntity.getGripPoints


getHandle ​

▸ getHandle(): string

得到对象句柄

Example

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

Returns ​

string

返回对象句柄

Inherited from ​

McDbCustomEntity.getHandle


getImp ​

▸ getImp(): any

获取内部实现对象。

Example

ts
import { McRxObject } from 'mxcad';

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

Returns ​

any

内部实现对象。

Inherited from ​

McDbCustomEntity.getImp


getJson ​

▸ getJson(): string

获取 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

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

Returns ​

string

JSON 格式的字符串。

Inherited from ​

McDbCustomEntity.getJson


getMTextImp ​

▸ getMTextImp(): MxCADMTextImp

Returns ​

MxCADMTextImp


getName ​

▸ getName(): string

获取自定义对象名称

Returns ​

string

Overrides ​

McDbCustomEntity.getName


getObjectID ​

▸ getObjectID(): McObjectId

获取对象 ID。

Example

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

Returns ​

McObjectId

对象 ID。

Inherited from ​

McDbCustomEntity.getObjectID


getOwnerID ​

▸ getOwnerID(): number

得到对象拥用者的id

Example

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

Returns ​

number

Inherited from ​

McDbCustomEntity.getOwnerID


getTypeName ​

▸ getTypeName(): string

获取自定义实体的类型名称。

Returns ​

string

自定义实体的类型名称

Overrides ​

McDbCustomEntity.getTypeName


getxData ​

▸ getxData(appName?): MxCADResbuf

得到对象的扩展数据

Example

ts
// 假设ent为有效实例对象
const xData = ent.getXData();

Parameters ​

NameTypeDefault valueDescription
appNamestring""扩展数据名

Returns ​

MxCADResbuf

Inherited from ​

McDbCustomEntity.getxData


getxDataDouble ​

▸ getxDataDouble(appName): Object

获取实体的指定 XData 类型中的 double 值

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataDouble("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称

Returns ​

Object

double 值

NameType
retboolean
valnumber

Inherited from ​

McDbCustomEntity.getxDataDouble


getxDataLong ​

▸ getxDataLong(appName): Object

获取实体的指定 XData 类型中的 long(整数)值

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataLong("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称

Returns ​

Object

long 值

NameType
retboolean
valnumber

Inherited from ​

McDbCustomEntity.getxDataLong


getxDataPoint ​

▸ getxDataPoint(appName): Object

获取实体的指定 XData 类型中的点对象

Parameters ​

NameTypeDescription
appNamestring扩展数据名称

Returns ​

Object

获取结果及三维点对象

NameType
retboolean
valMcGePoint3d

Inherited from ​

McDbCustomEntity.getxDataPoint


getxDataString ​

▸ getxDataString(appName): Object

获取与特定实体关联的 XData 信息,并以字符串形式返回

Example

ts
// 假设ent为有效实例对象
let data = ent.getxDataString("DataName");
if(data.ret){
  console.log(data.val)
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称

Returns ​

Object

val XData信息 | ret 是否返回成功

NameType
retboolean
valstring

Inherited from ​

McDbCustomEntity.getxDataString


highlight ​

▸ highlight(isHighlight): void

设置对象是否高亮

Example

ts
import { McDbEntity } from 'mxcad'
const ent = new McDbEntity()
ent.highlight(true);

Parameters ​

NameTypeDescription
isHighlightboolean是否高亮

Returns ​

void

Inherited from ​

McDbCustomEntity.highlight


initTempObject ​

▸ initTempObject(imp): void

初始化临时对象。

Example

ts
import { McRxObject } from 'mxcad';

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

Parameters ​

NameTypeDescription
impany内部实现对象。

Returns ​

void

Inherited from ​

McDbCustomEntity.initTempObject


isErased ​

▸ isErased(): boolean

对象是否已经删除

Example

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

Returns ​

boolean

Inherited from ​

McDbCustomEntity.isErased


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Example

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

Returns ​

boolean

Inherited from ​

McDbCustomEntity.isHaveExtensionDictionary


isKindOf ​

▸ isKindOf(sObjectName): boolean

判断对象类型

Example

ts
import { McRxObject } from 'mxcad';

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

Parameters ​

NameTypeDescription
sObjectNamestring类型名

Returns ​

boolean

返回对象是否是目标类型

Inherited from ​

McDbCustomEntity.isKindOf


isNull ​

▸ isNull(): any

判断是否为空对象

Example

ts
import { McRxObject } from 'mxcad';

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

Returns ​

any

Inherited from ​

McDbCustomEntity.isNull


mirror ​

▸ mirror(point1, point2): boolean

镜向对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.mirror(new McGePoint3d(0,0,0), new McGePoint3d(20,10,0))

Parameters ​

NameTypeDescription
point1McGePoint3d镜像基点
point2McGePoint3d-

Returns ​

boolean

Inherited from ​

McDbCustomEntity.mirror


move ​

▸ move(fromPoint, toPoint): boolean

移动对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.move(new McGePoint3d(0,0,0), new McGePoint3d(20,0,0))

Parameters ​

NameTypeDescription
fromPointMcGePoint3d移动开始点
toPointMcGePoint3d移动结束点

Returns ​

boolean

Inherited from ​

McDbCustomEntity.move


moveGripPointsAt ​

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

移动自定义对象的夹点。

Example

ts
  import { McDbCustomEntity, MxCADWorldDraw, McDbLine } from 'mxcad';
  // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity
  class McDbTestLineCustomEntity extends McDbCustomEntity {
       // 定义McDbTestLineCustomEntity内部的点对象 pt1、pt2
       private pt1: McGePoint3d = new McGePoint3d();
       private pt2: McGePoint3d = new McGePoint3d();
       // 移动自定义对象的夹点。
       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;
           }
       };
   }

Parameters ​

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

Returns ​

void

Overrides ​

McDbCustomEntity.moveGripPointsAt


rotate ​

▸ rotate(basePoint, dRotationAngle): boolean

旋转对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.rotate(new McGePoint3d(0,0,0), Math.PI)

Parameters ​

NameTypeDescription
basePointMcGePoint3d旋转基点
dRotationAnglenumber旋转角度

Returns ​

boolean

Inherited from ​

McDbCustomEntity.rotate


rxInit ​

▸ rxInit(): void

自定义实体注册

Example

ts
import { MxFun } from 'mxdraw
// MxCAD创建成功
MxFun.on("mxcadApplicationCreatedMxCADObject", (param) => {
// McDbTestLineCustomEntity 自定义实体
  new McDbTestLineCustomEntity().rxInit();// 自定义实体注册
  MxFun.addCommand("MxTest_DrawCustomEntity");// 注册绘制实体命令
})

Returns ​

void

Inherited from ​

McDbCustomEntity.rxInit


scaleEntity ​

▸ scaleEntity(basePoint, dScaleFactor): boolean

缩放对象

Example

ts
import { McDbEntity, McGePoint3d } from 'mxcad'
const ent = new McDbEntity()
ent.scaleEntity(new McGePoint3d(0,0,0), 0.5)

Parameters ​

NameTypeDescription
basePointMcGePoint3d缩放基点
dScaleFactornumber缩放因子(<1 缩小; >1 放大)

Returns ​

boolean

Inherited from ​

McDbCustomEntity.scaleEntity


setJson ​

▸ setJson(str): boolean

设置 JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

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

Parameters ​

NameTypeDescription
strstringJSON 格式的字符串。

Returns ​

boolean

是否设置成功。

Inherited from ​

McDbCustomEntity.setJson


setxData ​

▸ setxData(xdata): boolean

设置对象的扩展数据

Example

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

//设置扩展数据
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
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"}]));

Parameters ​

NameTypeDescription
xdataMxCADResbuf扩展数据链表

Returns ​

boolean

Inherited from ​

McDbCustomEntity.setxData


setxDataDouble ​

▸ setxDataDouble(appName, val): boolean

设置实体的指定 XData 类型中的 double 值

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
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){
  //设置成功
}else{
  //设置失败
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称
valnumberdouble 值

Returns ​

boolean

布尔值

Inherited from ​

McDbCustomEntity.setxDataDouble


setxDataLong ​

▸ setxDataLong(appName, val): boolean

设置实体的指定 XData 类型中的 long(整数)值

Example

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

let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
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){
  //设置成功
}else{
  //设置失败
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称
valnumberlong 值

Returns ​

boolean

long 值

Inherited from ​

McDbCustomEntity.setxDataLong


setxDataPoint ​

▸ setxDataPoint(appName, val): boolean

设置实体的指定 XData 类型中的点对象

Parameters ​

NameTypeDescription
appNamestring扩展数据名称
valMcGePoint3d点对象

Returns ​

boolean

获取结果及三维点对象

Inherited from ​

McDbCustomEntity.setxDataPoint


setxDataString ​

▸ setxDataString(appName, val): boolean

设置与特定实体关联的 XData 信息,并以字符串形式设置

Example

ts
import { MxCADUiPrEntity, McDbEntity } from "mxcad";
let selEntity = new MxCADUiPrEntity();
selEntity.setMessage("选择对象");
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){
  //设置成功
}else{
  //设置失败
}

Parameters ​

NameTypeDescription
appNamestring扩展数据名称
valstring字符串值

Returns ​

boolean

是否设置成功

Inherited from ​

McDbCustomEntity.setxDataString


syncData ​

▸ syncData(toCpp?): boolean

js 对像的数据与McDbCustomEntity::m_mapData的同步。

Parameters ​

NameTypeDefault value
toCppbooleantrue

Returns ​

boolean

Inherited from ​

McDbCustomEntity.syncData


unErase ​

▸ unErase(): boolean

反删除对象。

Example

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

Returns ​

boolean

Inherited from ​

McDbCustomEntity.unErase


updateDisplay ​

▸ updateDisplay(): void

显示调用对象更新显示.

Example

ts
// 假设ent为有效实例对象
ent.updateDisplay()

Returns ​

void

Inherited from ​

McDbCustomEntity.updateDisplay


worldDraw ​

▸ worldDraw(draw): void

绘制自定义实体

Example

ts
  import { McDbCustomEntity, MxCADWorldDraw, McDbLine } from 'mxcad'
  // 新创建 McDbTestLineCustomEntity 类继承 McDbCustomEntity
  class McDbTestLineCustomEntity extends McDbCustomEntity {
     // 定义McDbTestLineCustomEntity内部的点对象 pt1、pt2
     private pt1: McGePoint3d = new McGePoint3d();
     private pt2: McGePoint3d = new McGePoint3d();
     //绘制实体
     public worldDraw(draw: MxCADWorldDraw): void {
       let tmpline = new McDbLine(this.pt1, this.pt2);
       draw.drawEntity(tmpline);
     }
   }

Parameters ​

NameType
drawMxCADWorldDraw

Returns ​

void

Overrides ​

McDbCustomEntity.worldDraw