Skip to content

mxcad_2d API 文档 / 2d / McDbTextStyleTable

Class: McDbTextStyleTable ​

2d.McDbTextStyleTable

McDbTextStyleTable 是数据库中的文字样式表,用于管理当前图纸中的所有文字样式定义。

Description

该类用于维护与访问文字样式集合,支持文字样式的查看、创建和名称检索。 通过它可以完成:

  • 获取全部文字样式记录 ID;
  • 添加新的文字样式;
  • 按名称查找指定样式;
  • 判断样式是否存在;
  • 后续通过对象 ID 获取 McDbTextStyleTableRecord 进行参数设置。

使用方式:

  1. 从数据库中获取文字样式表 MxCpp.getCurrentMxCAD().getDatabase().getTextStyleTable();
  2. 调用 getAllRecordId() 获取所有样式;
  3. 使用 add() / get() / has() 管理样式;
  4. 将选中的样式用于文字对象或注释对象。

总结:在实际开发中,McDbTextStyleTable 主要用于统一管理文字样式,是文本对象字体、尺寸和排版控制的基础入口。

Example

ts
// 获取所有文字样式
import { MxCpp, McDbTextStyleTable } from "mxcad"
  // 获取当前CAD对象
  let mxcad = MxCpp.getCurrentMxCAD();
  // 获取数据库文字样式表
  let textSyleTable: McDbTextStyleTable = mxcad.getDatabase().getTextStyleTable();
  // 获取文字样式表中的所有文字样式表记录对象ID
  let aryId = textSyleTable.getAllRecordId();
  // 遍历文字样式表记录对象
  aryId.forEach((id) => {
      let textSyleRec = id.getMcDbTextStyleTableRecord();
      if (textSyleRec === null) return;
      console.log(textSyleRec);
      console.log("textSyleRec.fileName:" + textSyleRec.fileName);
      console.log("textSyleRec.name:" + textSyleRec.name);
  });

Hierarchy ​

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new McDbTextStyleTable(imp?)

构造函数。

Parameters ​

NameTypeDescription
imp?any内部实现对象。

Overrides ​

McDbObject.constructor

Properties ​

imp ​

• imp: any = 0

内部实现对象。

Inherited from ​

McDbObject.imp

Accessors ​

dxf0 ​

• get dxf0(): string

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

Returns ​

string

Inherited from ​

McDbObject.dxf0


objectName ​

• get objectName(): string

获取对象名称。

Returns ​

string

返回对象名

Inherited from ​

McDbObject.objectName

Methods ​

add ​

▸ add(rec): McObjectId

向文字样式表中添加文字样式记录。

Parameters ​

NameTypeDescription
recMcDbTextStyleTableRecord文字样式表记录对象。

Returns ​

McObjectId

新增文字样式记录对象ID。

Example

ts
import { MxCpp, McDbTextStyleTable } from "mxcad"

let mxcad = MxCpp.getCurrentMxCAD();
let textSyleTable: McDbTextStyleTable = mxcad.getDatabase().getTextStyleTable();

const newTextStyleRecord = new McDbTextStyleTableRecord();
const id = textSyleTable.add(newTextStyleRecord);
console.log(id)

assertObjectModification ​

▸ assertObjectModification(autoUndo?): number

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

Parameters ​

NameTypeDefault valueDescription
autoUndobooleanfalse这次修改是否要自动支持撤销,默认为false

Returns ​

number

Inherited from ​

McDbObject.assertObjectModification


clone ​

▸ clone(): null | McDbObject

克隆对象。

Returns ​

null | McDbObject

克隆出的对象。

Inherited from ​

McDbObject.clone


createExtensionDictionary ​

▸ createExtensionDictionary(): boolean

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

Returns ​

boolean

Inherited from ​

McDbObject.createExtensionDictionary


erase ​

▸ erase(): boolean

删除对象。

Returns ​

boolean

是否删除成功。

Inherited from ​

McDbObject.erase


get ​

▸ get(sName, skipDeleted?): McObjectId

查找文字样式表中的文字样式记录。

Parameters ​

NameTypeDefault valueDescription
sNamestringundefined文字样式名称。
skipDeletedbooleantrue是否跳过已删除文字样式。

Returns ​

McObjectId

文字样式记录对象ID。


getAllRecordId ​

▸ getAllRecordId(skipDeleted?): McObjectId[]

获取文字样式表中的所有文字样式记录的ID。

Parameters ​

NameTypeDefault valueDescription
skipDeletedbooleantrue是否跳过已删除文字样式。

Returns ​

McObjectId[]

ret 文字样式ID数组。


getDatabase ​

▸ getDatabase(): McDbDatabase

得到对象所在的数据库

Returns ​

McDbDatabase

返回数据库

Inherited from ​

McDbObject.getDatabase


getDatabaseIndexId ​

▸ getDatabaseIndexId(): number

获取对象的索引ID

Returns ​

number

Inherited from ​

McDbObject.getDatabaseIndexId


getExtensionDictionary ​

▸ getExtensionDictionary(): McDbDictionary

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

Returns ​

McDbDictionary

扩展字典数据

Inherited from ​

McDbObject.getExtensionDictionary


getGripEditBasePointsIndex ​

▸ getGripEditBasePointsIndex(): number[]

获取对象的夹点对应的编辑基点索引。

Returns ​

number[]

Inherited from ​

McDbObject.getGripEditBasePointsIndex


getGripPoints ​

▸ getGripPoints(): McGePoint3dArray

获取对象的夹点数组

Returns ​

McGePoint3dArray

Inherited from ​

McDbObject.getGripPoints


getHandle ​

▸ getHandle(): string

得到对象句柄

Returns ​

string

返回对象句柄

Inherited from ​

McDbObject.getHandle


getImp ​

▸ getImp(): any

获取内部实现对象。

Returns ​

any

内部实现对象。

Inherited from ​

McDbObject.getImp


getJson ​

▸ getJson(): string

获取 JSON 格式的字符串。

Returns ​

string

JSON 格式的字符串。

Inherited from ​

McDbObject.getJson


getObjectID ​

▸ getObjectID(): McObjectId

获取对象 ID。

Returns ​

McObjectId

对象 ID。

Inherited from ​

McDbObject.getObjectID


getOwnerID ​

▸ getOwnerID(): number

得到对象拥用者的id

Returns ​

number

Inherited from ​

McDbObject.getOwnerID


has ​

▸ has(sName, skipDeleted?): boolean

检查文字样式表中是否存在指定名称的文字样式记录。

Parameters ​

NameTypeDefault valueDescription
sNamestringundefined文字样式名称。
skipDeletedbooleantrue是否跳过已删除文字样式。

Returns ​

boolean

布尔值。


initTempObject ​

▸ initTempObject(imp): void

初始化临时对象。

Parameters ​

NameTypeDescription
impany内部实现对象。

Returns ​

void

Inherited from ​

McDbObject.initTempObject


isErased ​

▸ isErased(): boolean

对象是否已经删除

Returns ​

boolean

Inherited from ​

McDbObject.isErased


isHaveExtensionDictionary ​

▸ isHaveExtensionDictionary(): boolean

是否有扩展字典数据.

Returns ​

boolean

Inherited from ​

McDbObject.isHaveExtensionDictionary


isKindOf ​

▸ isKindOf(sObjectName): boolean

判断对象类型

Parameters ​

NameTypeDescription
sObjectNamestring类型名

Returns ​

boolean

返回对象是否是目标类型

Inherited from ​

McDbObject.isKindOf


isNull ​

▸ isNull(): any

判断是否为空对象

Returns ​

any

Inherited from ​

McDbObject.isNull


moveGripPointsAt ​

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

移动对象的夹点

Parameters ​

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

Returns ​

any

Inherited from ​

McDbObject.moveGripPointsAt


setJson ​

▸ setJson(str): boolean

设置 JSON 格式的字符串。

Parameters ​

NameTypeDescription
strstringJSON 格式的字符串。

Returns ​

boolean

是否设置成功。

Inherited from ​

McDbObject.setJson


unErase ​

▸ unErase(): boolean

反删除对象。

Returns ​

boolean

Inherited from ​

McDbObject.unErase