Skip to content
On this page

mxcad_2d API 文档 / 2d / McDbAttributeDefinition

Class: McDbAttributeDefinition

2d.McDbAttributeDefinition

用于定义块属性的属性定义,并提供了一些方法来获取和设置属性的各种参数

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbAttributeDefinition(imp?)

构造函数。

Parameters

NameTypeDescription
imp?any实现对象。

Overrides

McDbText.constructor

Properties

imp

imp: any = 0

内部实现对象。

Inherited from

McDbText.imp

Accessors

alignmentPoint

get alignmentPoint(): McGePoint3d

获取文字的对齐点。

Returns

McGePoint3d

Example

ts
// 假设text为有效文本实体
const alignmentPoint = text.alignmentPoint;

Inherited from

McDbText.alignmentPoint

set alignmentPoint(pt): void

设置文字的对齐点。

Parameters

NameTypeDescription
ptMcGePoint3d三维点向量

Returns

void

Example

ts
import { McDbText, McGePoint3d } from "mxcad";

const text = new McDbText();
text.alignmentPoint = new McGePoint3d(0,0,0);
console.log(text.alignmentPoint)//(0,0,0)

Inherited from

McDbText.alignmentPoint


colorIndex

get colorIndex(): number

得到对象颜色索引

Returns

number

Example

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

Inherited from

McDbText.colorIndex

set colorIndex(val): void

设置对象颜色索引

Parameters

NameTypeDescription
valnumber颜色索引(ColorIndexType)

Returns

void

Inherited from

McDbText.colorIndex


drawOrder

get drawOrder(): number

对象的显示顺序

Returns

number

Example

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

Inherited from

McDbText.drawOrder

set drawOrder(order): void

对象的显示顺序

Parameters

NameTypeDescription
ordernumber顺序值

Returns

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;
  }
})

Inherited from

McDbText.drawOrder


dxf0

get dxf0(): string

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

Returns

string

Inherited from

McDbText.dxf0


height

get height(): number

获取文字的高度。

Returns

number

Example

ts
// 假设text为有效文本实体
const height = text.height;

Inherited from

McDbText.height

set height(val): void

设置文字高度

Parameters

NameTypeDescription
valnumber高度

Returns

void

Example

ts
import { McDbText } from "mxcad";

const text = new McDbText();
text.height = 20;
console.log(text.height)//20

Inherited from

McDbText.height


horizontalMode

get horizontalMode(): TextHorzMode

获取文字的水平对齐方式。

Returns

TextHorzMode

Example

ts
// 假设text为有效文本实体
const horizontalMode = text.horizontalMode;

Inherited from

McDbText.horizontalMode

set horizontalMode(val): void

设置文字的水平对齐方式。

Parameters

NameTypeDescription
valTextHorzMode文字水平对齐方式

Returns

void

Example

ts
import { McDbText, McDb } from "mxcad";

const text = new McDbText();
text.horizontalMode = McDb.TextHorzMode.kTextAlign;
console.log(text.horizontalMode)//3

Inherited from

McDbText.horizontalMode


isConstant

get isConstant(): boolean

获取指示属性是否是常量

Returns

boolean

set isConstant(val): void

设置指示属性是否是常量

Parameters

NameType
valboolean

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.isConstant = true; // 设置属性为常量
console.log(attribute.isConstant); // 获取属性是否是常量

isInvisible

get isInvisible(): boolean

获取是否可见

Returns

boolean

set isInvisible(val): void

设置是否可见

Parameters

NameType
valboolean

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.isInvisible = true; // 设置属性为不可见
console.log(attribute.isInvisible); // 获取属性是否可见

isPreset

get isPreset(): boolean

获取属性是否预设

Returns

boolean

set isPreset(val): void

设置属性是否预设

Parameters

NameType
valboolean

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.isPreset = true; // 设置属性预设
console.log(attribute.isPreset); // 获取属性是否预设

isVerifiable

get isVerifiable(): boolean

获取属性是否可验证

Returns

boolean

set isVerifiable(val): void

设置属性是否可验证

Parameters

NameType
valboolean

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.isVerifiable = true; // 设置属性可验证
console.log(attribute.isVerifiable); // 获取属性是否可验证

layer

get layer(): string

得到对象图层名

Returns

string

Inherited from

McDbText.layer

set layer(val): void

设置对象图层名

Parameters

NameTypeDescription
valstring图层名

Returns

void

Example

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

Inherited from

McDbText.layer


layerId

get layerId(): McObjectId

获取图层ID对象

Returns

McObjectId

Example

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

Inherited from

McDbText.layerId

set layerId(id): void

设置图层Id对象

Parameters

NameType
idMcObjectId

Returns

void

Example

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

Inherited from

McDbText.layerId


linetype

get linetype(): string

得到对象线型名

Returns

string

Inherited from

McDbText.linetype

set linetype(val): void

设置对象线型名

Parameters

NameTypeDescription
valstring线型名

Returns

void

Example

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

Inherited from

McDbText.linetype


linetypeId

get linetypeId(): McObjectId

获取实体对象线型ID

Returns

McObjectId

Example

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

Inherited from

McDbText.linetypeId

set linetypeId(id): void

设置实体对象线型ID

Parameters

NameType
idMcObjectId

Returns

void

Example

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

Inherited from

McDbText.linetypeId


linetypeScale

get linetypeScale(): number

得到对象线型比例

Returns

number

Inherited from

McDbText.linetypeScale

set linetypeScale(val): void

设置对象线型比例

Parameters

NameTypeDescription
valnumber线型比例

Returns

void

Example

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

Inherited from

McDbText.linetypeScale


lineweight

get lineweight(): number

得到对象线重

Returns

number

Inherited from

McDbText.lineweight

set lineweight(val): void

设置对象线重

Parameters

NameTypeDescription
valnumber线重

Returns

void

Example

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

Inherited from

McDbText.lineweight


normal

get normal(): McGeVector3d

返回对象的normal

Returns

McGeVector3d

Example

ts

Inherited from

McDbText.normal

set normal(val): void

设置对象的normal

Parameters

NameType
valMcGeVector3d

Returns

void

Example

ts

Inherited from

McDbText.normal


objectName

get objectName(): string

获取对象名称。

Returns

string

返回对象名

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.objectName


oblique

get oblique(): number

获取文字的倾斜角度。

Returns

number

Example

ts
// 假设text为有效文本实体
const oblique = text.oblique;

Inherited from

McDbText.oblique

set oblique(val): void

设置文字的倾斜角度。

Parameters

NameType
valnumber

Returns

void

Example

ts
import { McDbText } from "mxcad";

const text = new McDbText();
text.oblique = Math.PI/4;
console.log(text.oblique)//45

Inherited from

McDbText.oblique


position

get position(): McGePoint3d

获取文字的位置。

Returns

McGePoint3d

Example

ts
// 假设text为有效文本实体
const position = text.position;

Inherited from

McDbText.position

set position(pt): void

设置文字的位置。

Parameters

NameTypeDescription
ptMcGePoint3d三维点向量

Returns

void

Example

ts
import { McDbText, McGePoint3d } from "mxcad";

const text = new McDbText();
text.position = new McGePoint3d(0,0,0);
console.log(text.position)//(0,0,0)

Inherited from

McDbText.position


prompt

get prompt(): string

获取插入块实例时,提示用户输入值的文本

Returns

string

set prompt(val): void

设置插入块实例时,提示用户输入值的文本

Parameters

NameType
valstring

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.prompt = "Enter value here"; // 设置属性的提示文本
console.log(attribute.prompt); // 获取属性的提示文本

rotation

get rotation(): number

获取文字的旋转角度。

Returns

number

Example

ts
// 假设text为有效文本实体
const rotation = text.rotation;

Inherited from

McDbText.rotation

set rotation(pt): void

设置文字的旋转角度。

Parameters

NameType
ptnumber

Returns

void

Example

ts
import { McDbText } from "mxcad";

const text = new McDbText();
text.rotation = Math.PI/4;
console.log(text.rotation)//45

Inherited from

McDbText.rotation


tag

get tag(): string

获取文字的字符串。

Returns

string

set tag(val): void

设置文字的字符串

Parameters

NameType
valstring

Returns

void

Example

ts
import { McDbAttributeDefinition } from "mxcad";

const attribute = new McDbAttributeDefinition();
attribute.tag = "TagName"; // 设置属性标签
console.log(attribute.tag); // 获取属性标签

textString

get textString(): string

获取文字的字符串。

Returns

string

Example

ts
// 假设text为有效文本实体
const textString = text.textString;

Inherited from

McDbText.textString

set textString(val): void

设置文字的字符串。

Parameters

NameTypeDescription
valstring字符串

Returns

void

Example

ts
import { McDbText } from "mxcad";

const text = new McDbText();
text.textString = "测试文本";
console.log(text.textString)//测试文本

Inherited from

McDbText.textString


textStyle

get textStyle(): string

得到对象文字样式

Returns

string

Inherited from

McDbText.textStyle

set textStyle(val): void

设置对象文字样式

Parameters

NameTypeDescription
valstring文字样式名

Returns

void

Example

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

Inherited from

McDbText.textStyle


textStyleId

get textStyleId(): McObjectId

获取实体文字样式

Returns

McObjectId

Example

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

Inherited from

McDbText.textStyleId

set textStyleId(id): void

设置实体的文字样式

Parameters

NameType
idMcObjectId

Returns

void

Example

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

Inherited from

McDbText.textStyleId


trueColor

get trueColor(): McCmColor

得到对象颜色

Returns

McCmColor

Example

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

Inherited from

McDbText.trueColor

set trueColor(val): void

设置对象颜色

Parameters

NameType
valMcCmColor

Returns

void

Inherited from

McDbText.trueColor


verticalMode

get verticalMode(): TextVertMode

获取文字的垂直对齐方式。

Returns

TextVertMode

Example

ts
// 假设text为有效文本实体
const verticalMode = text.verticalMode;

Inherited from

McDbText.verticalMode

set verticalMode(val): void

设置文字的垂直对齐方式。

Parameters

NameTypeDescription
valTextVertMode文字垂直对齐方式

Returns

void

Example

ts
import { McDbText, McDb } from "mxcad";

const text = new McDbText();
text.verticalMode = McDb.TextVertMode.kTextVertMid;
console.log(text.verticalMode)//2

Inherited from

McDbText.verticalMode


visible

get visible(): boolean

对象是否可见

Returns

boolean

Inherited from

McDbText.visible

set visible(val): void

设置是否可见

Parameters

NameTypeDescription
valboolean布尔值

Returns

void

Example

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

Inherited from

McDbText.visible


widthFactor

get widthFactor(): number

获取文字的宽度因子。

Returns

number

Example

ts
// 假设text为有效文本实体
const widthFactor = text.widthFactor;

Inherited from

McDbText.widthFactor

set widthFactor(val): void

设置文字的宽度因子。

Parameters

NameTypeDescription
valnumber宽度因子

Returns

void

Example

ts
import { McDbText } from "mxcad";

const text = new McDbText();
text.height = 0.8;
console.log(text.height)//0.8

Inherited from

McDbText.widthFactor

Methods

IntersectWith

IntersectWith(intersectObject, exOption): McGePoint3dArray

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

Parameters

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

Returns

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)

Inherited from

McDbText.IntersectWith


assertObjectModification

assertObjectModification(autoUndo?): number

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

Parameters

NameTypeDefault value
autoUndobooleanfalse

Returns

number

Example

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

Inherited from

McDbText.assertObjectModification


clone

clone(): null | McDbObject

克隆对象。

Returns

null | McDbObject

克隆出的对象。

Example

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

Inherited from

McDbText.clone


createExtensionDictionary

createExtensionDictionary(): boolean

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

Returns

boolean

Example

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

Inherited from

McDbText.createExtensionDictionary


deleteXData

deleteXData(appName): boolean

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

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

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
  //删除失败
}

Inherited from

McDbText.deleteXData


disableDisplay

disableDisplay(isDisable): void

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

Parameters

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

Returns

void

Example

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

Inherited from

McDbText.disableDisplay


erase

erase(): boolean

删除对象。

Returns

boolean

是否删除成功。

Example

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

Inherited from

McDbText.erase


explode

explode(): MxCADResbuf

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

Returns

MxCADResbuf

resbuf 数据

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();

Inherited from

McDbText.explode


getAllAppName

getAllAppName(): McGeStringArray

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

Returns

McGeStringArray

Example

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

Inherited from

McDbText.getAllAppName


getArea

getArea(): Object

计算面积

Returns

Object

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

NameType
retboolean
valnumber

Example

ts
import { McGePoint3d, McDbCircle } from "mxcad"

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

Inherited from

McDbText.getArea


getBoundingBox

getBoundingBox(): Object

得到对象的最小外包

Returns

Object

NameType
maxPtMcGePoint3d
minPtMcGePoint3d
retboolean

Example

ts
import { McDbText, McGePoint3d } from 'mxcad'
const text = new McDbText();
text.textString = "测试Test";
text.height = 20;
text.position = text.alignmentPoint = new McGePoint3d(0,0,0);
const { minPt, maxPt, ret } = text.getBoundingBox()

Inherited from

McDbText.getBoundingBox


getDatabase

getDatabase(): McDbDatabase

得到对象所在的数据库

Returns

McDbDatabase

返回数据库

Example

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

Inherited from

McDbText.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

获取对象的索引ID

Returns

number

Example

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

Inherited from

McDbText.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

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

Returns

McDbDictionary

扩展字典数据

Example

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

Inherited from

McDbText.getExtensionDictionary


getGripPoints

getGripPoints(): McGePoint3dArray

获取对象的控制点

Returns

McGePoint3dArray

Example

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

Inherited from

McDbText.getGripPoints


getHandle

getHandle(): string

得到对象句柄

Returns

string

返回对象句柄

Example

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

Inherited from

McDbText.getHandle


getImp

getImp(): any

获取内部实现对象。

Returns

any

内部实现对象。

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.getImp


getJson

getJson(): string

获取 JSON 格式的字符串。

Returns

string

JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.getJson


getObjectID

getObjectID(): McObjectId

获取对象 ID。

Returns

McObjectId

对象 ID。

Example

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

Inherited from

McDbText.getObjectID


getOwnerID

getOwnerID(): number

得到对象拥用者的id

Returns

number

Example

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

Inherited from

McDbText.getOwnerID


getxData

getxData(appName?): MxCADResbuf

得到对象的扩展数据

Parameters

NameTypeDefault valueDescription
appNamestring""扩展数据名

Returns

MxCADResbuf

Example

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

Inherited from

McDbText.getxData


getxDataDouble

getxDataDouble(appName): Object

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

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

double 值

NameType
retboolean
valnumber

Example

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

Inherited from

McDbText.getxDataDouble


getxDataLong

getxDataLong(appName): Object

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

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

long 值

NameType
retboolean
valnumber

Example

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

Inherited from

McDbText.getxDataLong


getxDataPoint

getxDataPoint(appName): Object

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

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

获取结果及三维点对象

NameType
retboolean
valMcGePoint3d

Inherited from

McDbText.getxDataPoint


getxDataString

getxDataString(appName): Object

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

Parameters

NameTypeDescription
appNamestring扩展数据名称

Returns

Object

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

NameType
retboolean
valstring

Example

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

Inherited from

McDbText.getxDataString


highlight

highlight(isHighlight): void

设置对象是否高亮

Parameters

NameTypeDescription
isHighlightboolean是否高亮

Returns

void

Example

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

Inherited from

McDbText.highlight


initTempObject

initTempObject(imp): void

初始化临时对象。

Parameters

NameTypeDescription
impany内部实现对象。

Returns

void

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.initTempObject


isErased

isErased(): boolean

对象是否已经删除

Returns

boolean

Example

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

Inherited from

McDbText.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Returns

boolean

Example

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

Inherited from

McDbText.isHaveExtensionDictionary


isKindOf

isKindOf(sObjectName): boolean

判断对象类型

Parameters

NameTypeDescription
sObjectNamestring类型名

Returns

boolean

返回对象是否是目标类型

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.isKindOf


isNull

isNull(): any

判断是否为空对象

Returns

any

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.isNull


mirror

mirror(point1, point2): boolean

镜向对象

Parameters

NameTypeDescription
point1McGePoint3d镜像基点
point2McGePoint3d-

Returns

boolean

Example

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

Inherited from

McDbText.mirror


move

move(fromPoint, toPoint): boolean

移动对象

Parameters

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

Returns

boolean

Example

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

Inherited from

McDbText.move


moveGripPointsAt

moveGripPointsAt(iIndex, dXOffset, dYOffset, dZOffset): any

移动对象的控制点

Parameters

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

Returns

any

Example

ts
//假设obj为一个数据库对象
obj.moveGripPointsAt(1,10,10,10);

Inherited from

McDbText.moveGripPointsAt


rotate

rotate(basePoint, dRotationAngle): boolean

旋转对象

Parameters

NameTypeDescription
basePointMcGePoint3d旋转基点
dRotationAnglenumber旋转角度

Returns

boolean

Example

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

Inherited from

McDbText.rotate


scaleEntity

scaleEntity(basePoint, dScaleFactor): boolean

缩放对象

Parameters

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

Returns

boolean

Example

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

Inherited from

McDbText.scaleEntity


setJson

setJson(str): boolean

设置 JSON 格式的字符串。

Parameters

NameTypeDescription
strstringJSON 格式的字符串。

Returns

boolean

是否设置成功。

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbText.setJson


setxData

setxData(xdata): boolean

设置对象的扩展数据

Parameters

NameTypeDescription
xdataMxCADResbuf扩展数据链表

Returns

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"}]));

Inherited from

McDbText.setxData


setxDataDouble

setxDataDouble(appName, val): boolean

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

Parameters

NameTypeDescription
appNamestring扩展数据名称
valnumberdouble 值

Returns

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.setxDataDouble("DataName", 0);
if(res){
  //设置成功
}else{
  //设置失败
}

Inherited from

McDbText.setxDataDouble


setxDataLong

setxDataLong(appName, val): boolean

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

Parameters

NameTypeDescription
appNamestring扩展数据名称
valnumberlong 值

Returns

boolean

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{
  //设置失败
}

Inherited from

McDbText.setxDataLong


setxDataPoint

setxDataPoint(appName, val): boolean

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

Parameters

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

Returns

boolean

获取结果及三维点对象

Inherited from

McDbText.setxDataPoint


setxDataString

setxDataString(appName, val): boolean

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

Parameters

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

Returns

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.setxDataString("DataName", "xxxxx");
if(res){
  //设置成功
}else{
  //设置失败
}

Inherited from

McDbText.setxDataString


syncData

syncData(_toCpp?): boolean

同步实体的数据。这个方法可能是在修改了实体的属性或者附加了新的数据之后调用的,以确保所有的改变都被正确地保存到实体的数据库记录中。

Parameters

NameTypeDefault valueDescription
_toCppbooleantrue是否同步数据

Returns

boolean

Example

ts
// 假设ent为有效实例对象
const res = ent.syncData(true);
if(res){
  //同步成功
}else{
  //同步失败
}

Inherited from

McDbText.syncData


transformBy

transformBy(transformationMatrix): boolean

变换对象

Parameters

NameTypeDescription
transformationMatrixMcGeMatrix3d变换矩阵

Returns

boolean

Example

ts
import { McGeMatrix3d, McDbEntity, McGeVector3d} from 'mxcad'
 const ent = new McDbEntity()
   let matrix = new McGeMatrix3d();
   matrix.setToTranslation(new McGeVector3d(20,0,0));//平移
   ent.transformBy(matrix);

Inherited from

McDbText.transformBy


unErase

unErase(): boolean

反删除对象。

Returns

boolean

Example

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

Inherited from

McDbText.unErase


updateDisplay

updateDisplay(): void

显示调用对象更新显示.

Returns

void

Example

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

Inherited from

McDbText.updateDisplay