Skip to content
On this page

mxcad_2d API 文档 / 2d / McDbTextStyleTableRecord

Class: McDbTextStyleTableRecord

2d.McDbTextStyleTableRecord

表示一个文字样式表记录对象,实现了对文字的属性相关操作函数。

Example

ts
// 添加文字样式
   import { McCmColor, MxCpp, McDbTextStyleTableRecord, McDb } from "mxcad"

   const mxcad = MxCpp.getCurrentMxCAD();
   // 拿到当前文字样式表
   const textSyleTable = mxcad.getDatabase().getTextStyleTable();
   // 构造一个文字样式表记录对象
   let newTextStyleRecord = new McDbTextStyleTableRecord();
   // 设置对象文件名
   newTextStyleRecord.fileName = "txt.shx";
   // 设置对象大字体名称
   newTextStyleRecord.bigFontFileName = "hztxt.shx";
   // 设置对象文字大小
   newTextStyleRecord.textSize = 10;
   // 设置对象名
   newTextStyleRecord.name = sMyTextStyle;
   // 设置对象宽度因子
   newTextStyleRecord.xScale = 0.7;
   // 添加文字样式
   const res = textSyleTable.add(newTextStyleRecord).isValid()
   if (res) {
     console.log("add ok");
   }

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McDbTextStyleTableRecord(imp?)

构造函数。

Parameters

NameTypeDescription
imp?any内部实现对象。

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();

Overrides

McDbObject.constructor

Properties

imp

imp: any = 0

内部实现对象。

Inherited from

McDbObject.imp

Accessors

bigFontFileName

get bigFontFileName(): string

大字体文件名称

Returns

string

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.bigFontFileName = "测试";
console.log("大字体名称:",newTextStyleRecord.bigFontFileName)

set bigFontFileName(val): void

Parameters

NameType
valstring

Returns

void


dxf0

get dxf0(): string

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

Returns

string

Inherited from

McDbObject.dxf0


fileName

get fileName(): string

字体文件名称

Returns

string

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.fileName = "测试字体名";
console.log("当前字体文件名:",newTextStyleRecord.fileName)

set fileName(val): void

Parameters

NameType
valstring

Returns

void


flagBits

get flagBits(): number

获取或设置文本样式表记录的一组标志位

Returns

number

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
// 获取标志位的当前值
const currentFlagBits = newTextStyleRecord.flagBits;
console.log("当前标志位:", currentFlagBits);
// 设置新的标志位值
const newFlagBits = 0b101010; // 例如:使用二进制字面量来表示新的标志位值
newTextStyleRecord.flagBits = newFlagBits;
console.log("设置后的标志位:", newTextStyleRecord.flagBits);

set flagBits(val): void

Parameters

NameType
valnumber

Returns

void


isShapeFile

get isShapeFile(): boolean

获取或设置文本样式是否使用形状字体

Returns

boolean

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.isShapeFile = false;
console.log(newTextStyleRecord.isShapeFile) // false

set isShapeFile(val): void

Parameters

NameType
valboolean

Returns

void


isVertical

get isVertical(): boolean

获取或设置文本样式是否使用斜体

Returns

boolean

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.isVertical = false;
console.log(newTextStyleRecord.isVertical) // false

set isVertical(val): void

Parameters

NameType
valboolean

Returns

void


name

get name(): string

获取或设置文字样式名称。

Returns

string

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.name = "测试文字样式"
console.log(newTextStyleRecord.name) // 测试文字样式

set name(val): void

Parameters

NameType
valstring

Returns

void


objectName

get objectName(): string

获取对象名称。

Returns

string

返回对象名

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbObject.objectName


obliquingAngle

get obliquingAngle(): number

倾斜角度

Returns

number

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.obliquingAngle = Math.PI/4;
console.log(newTextStyleRecord.obliquingAngle) // 45

set obliquingAngle(val): void

Parameters

NameType
valnumber

Returns

void


textSize

get textSize(): number

文字大小(高度)

Returns

number

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.textSize = 20;
console.log(newTextStyleRecord.textSize) // 20

set textSize(val): void

Parameters

NameType
valnumber

Returns

void


xScale

get xScale(): number

Returns

number

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
newTextStyleRecord.xScale = 0.8;
console.log(newTextStyleRecord.xScale) // 0.8

set xScale(val): void

Parameters

NameType
valnumber

Returns

void

Methods

assertObjectModification

assertObjectModification(autoUndo?): number

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

Parameters

NameTypeDefault value
autoUndobooleanfalse

Returns

number

Example

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

Inherited from

McDbObject.assertObjectModification


clone

clone(): null | McDbObject

克隆对象。

Returns

null | McDbObject

克隆出的对象。

Example

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

Inherited from

McDbObject.clone


createExtensionDictionary

createExtensionDictionary(): boolean

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

Returns

boolean

Example

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

Inherited from

McDbObject.createExtensionDictionary


erase

erase(): boolean

删除对象。

Returns

boolean

是否删除成功。

Example

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

Inherited from

McDbObject.erase


font

font(): Object

获取字体样式

Returns

Object

sTypeface: 字体名称 | bold: 是否粗体 | italic: 是否斜体 | charset: 字符集 | pitchAndFamily: 字体间距和风格

NameType
boldboolean
charsetnumber
italicboolean
pitchAndFamilynumber
sTypefacestring

freeTempRelationObject

freeTempRelationObject(): void

释放临时关系对象

Returns

void

Example

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

Inherited from

McDbObject.freeTempRelationObject


getDatabase

getDatabase(): McDbDatabase

得到对象所在的数据库

Returns

McDbDatabase

返回数据库

Example

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

Inherited from

McDbObject.getDatabase


getDatabaseIndexId

getDatabaseIndexId(): number

获取对象的索引ID

Returns

number

Example

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

Inherited from

McDbObject.getDatabaseIndexId


getExtensionDictionary

getExtensionDictionary(): McDbDictionary

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

Returns

McDbDictionary

扩展字典数据

Example

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

Inherited from

McDbObject.getExtensionDictionary


getGripPoints

getGripPoints(): McGePoint3dArray

获取对象的控制点

Returns

McGePoint3dArray

Example

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

Inherited from

McDbObject.getGripPoints


getHandle

getHandle(): string

得到对象句柄

Returns

string

返回对象句柄

Example

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

Inherited from

McDbObject.getHandle


getImp

getImp(): any

获取内部实现对象。

Returns

any

内部实现对象。

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbObject.getImp


getJson

getJson(): string

获取 JSON 格式的字符串。

Returns

string

JSON 格式的字符串。

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbObject.getJson


getObjectID

getObjectID(): McObjectId

获取对象 ID。

Returns

McObjectId

对象 ID。

Example

ts
import { McDbObject } from "mxcad";

const obj = new McDbObject();
const id = obj.getObjectID();

Inherited from

McDbObject.getObjectID


getOwnerID

getOwnerID(): number

得到对象拥用者的id

Returns

number

Example

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

Inherited from

McDbObject.getOwnerID


initTempObject

initTempObject(imp): void

初始化临时对象。

Parameters

NameTypeDescription
impany内部实现对象。

Returns

void

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbObject.initTempObject


isErased

isErased(): boolean

对象是否已经删除

Returns

boolean

Example

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

Inherited from

McDbObject.isErased


isHaveExtensionDictionary

isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Returns

boolean

Example

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

Inherited from

McDbObject.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

McDbObject.isKindOf


isNull

isNull(): any

判断是否为空对象

Returns

any

Example

ts
import { McRxObject } from 'mxcad';

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

Inherited from

McDbObject.isNull


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

McDbObject.moveGripPointsAt


setFont

setFont(sTypeface, bold, italic, charset, pitchAndFamily): boolean

设置字体样式

Parameters

NameTypeDescription
sTypefacestring字体名称
boldboolean是否粗体
italicboolean是否斜体
charsetnumber字符集
pitchAndFamilynumber字体间距和风格

Returns

boolean

是否设置成功

Example

ts
import { McDbTextStyleTableRecord } from 'mxcad';

const newTextStyleRecord = new McDbTextStyleTableRecord();
// 设置字体
const typeface = "Arial"; // 字体名称
const isBold = true; // 是否粗体
const isItalic = false; // 是否斜体
const charset = 0; // 字符集
const pitchAndFamily = 0; // 字体间距和风格
const isSetFontSuccessful = newTextStyleRecord.setFont(typeface, isBold, isItalic, charset, pitchAndFamily);
// 检查设置是否成功
if (isSetFontSuccessful) {
 console.log("Font set successfully.");
} else {
 console.log("Failed to set font.");
}

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

McDbObject.setJson


tempRelationObject

tempRelationObject(): number

与对象相关的临时关系数

Returns

number

Inherited from

McDbObject.tempRelationObject


unErase

unErase(): boolean

反删除对象。

Returns

boolean

Example

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

Inherited from

McDbObject.unErase