mxcad_2d API 文档 / 2d / McDbDimStyleTable
Class: McDbDimStyleTable
2d.McDbDimStyleTable
McDbDimStyleTable 是数据库中的标注样式表,负责管理图纸中的所有标注样式定义。
Description
该类用于维护和访问 CAD 标注样式集合,适合对尺寸样式、文字样式、单位显示等标注相关属性进行统一管理。 通过它可以完成:
- 获取全部标注样式记录 ID;
- 新增和查询标注样式;
- 按名称判断样式是否存在;
- 后续通过对象 ID 访问具体的 McDbDimStyleTableRecord 继续设置样式参数。
使用方式:
- 通过数据库获取当前标注样式表;
- 使用 getAllRecordId() 列出全部样式;
- 调用 add() / get() / has() 管理样式;
- 将样式应用到当前标注对象或新创建的标注。
总结:在实际开发中,McDbDimStyleTable 是标注样式管理和尺寸规范控制的核心入口,适合统一设置标注风格。
Example
ts
import { MxCpp, McDbDimStyleTable } from "mxcad";
// 创建尺寸样式表并添加样式记录。
async function testDimStyleTable() {
const mxcad = MxCpp.getCurrentMxCAD();
const table: McDbDimStyleTable = mxcad.getDatabase().getDimStyleTable();
const ids = table.getAllRecordId();
console.log("标注样式数量:", ids.length);
}Hierarchy
↳
McDbDimStyleTable
Table of contents
Constructors
Properties
Accessors
Methods
- add
- assertObjectModification
- clone
- createExtensionDictionary
- erase
- get
- getAllRecordId
- getDatabase
- getDatabaseIndexId
- getExtensionDictionary
- getGripEditBasePointsIndex
- getGripPoints
- getHandle
- getImp
- getJson
- getObjectID
- getOwnerID
- has
- initTempObject
- isErased
- isHaveExtensionDictionary
- isKindOf
- isNull
- moveGripPointsAt
- setJson
- unErase
Constructors
constructor
• new McDbDimStyleTable(imp?)
构造函数。
Parameters
| Name | Type | Description |
|---|---|---|
imp? | any | 内部实现对象。 |
Overrides
Properties
imp
• imp: any = 0
内部实现对象。
Inherited from
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
| Name | Type | Description |
|---|---|---|
rec | McDbDimStyleTableRecord | 标注样式记录。 |
Returns
新增线型记录对象ID。
ts
___
### assertObjectModification
▸ **assertObjectModification**(`autoUndo?`): `number`
设置对象被改变的状态,可自动触发更新显示函数,更新显示。
比如块表记录更新了,需要通知块引用更新显示,可以调用该函数。
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `autoUndo` | `boolean` | `false` | 这次修改是否要自动支持撤销,默认为false |
#### Returns
`number`
#### Inherited from
[McDbObject](2d.McDbObject.md).[assertObjectModification](2d.McDbObject.md#assertobjectmodification)
___
### clone
▸ **clone**(): ``null`` \| [`McDbObject`](2d.McDbObject.md)
克隆对象。
#### Returns
``null`` \| [`McDbObject`](2d.McDbObject.md)
克隆出的对象。
#### Inherited from
[McDbObject](2d.McDbObject.md).[clone](2d.McDbObject.md#clone)
___
### createExtensionDictionary
▸ **createExtensionDictionary**(): `boolean`
创建对象的扩展字典数据.
#### Returns
`boolean`
#### Inherited from
[McDbObject](2d.McDbObject.md).[createExtensionDictionary](2d.McDbObject.md#createextensiondictionary)
___
### erase
▸ **erase**(): `boolean`
删除对象。
#### Returns
`boolean`
是否删除成功。
#### Inherited from
[McDbObject](2d.McDbObject.md).[erase](2d.McDbObject.md#erase)
___
### get
▸ **get**(`sName`, `skipDeleted?`): [`McObjectId`](2d.McObjectId.md)
查找标注样式表中的标注样式记录。
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `sName` | `string` | `undefined` | 标注样式名称。 |
| `skipDeleted` | `boolean` | `true` | 是否跳过已删除标注样式。 |
#### Returns
[`McObjectId`](2d.McObjectId.md)
标注样式记录对象ID。
___
### getAllRecordId
▸ **getAllRecordId**(`skipDeleted?`): [`McObjectId`](2d.McObjectId.md)[]
获取所有的注样式。
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `skipDeleted` | `boolean` | `true` | 是否跳过已删除注样式。 |
#### Returns
[`McObjectId`](2d.McObjectId.md)[]
注样式ID数组
___
### getDatabase
▸ **getDatabase**(): [`McDbDatabase`](2d.McDbDatabase.md)
得到对象所在的数据库
#### Returns
[`McDbDatabase`](2d.McDbDatabase.md)
返回数据库
#### Inherited from
[McDbObject](2d.McDbObject.md).[getDatabase](2d.McDbObject.md#getdatabase)
___
### getDatabaseIndexId
▸ **getDatabaseIndexId**(): `number`
获取对象的索引ID
#### Returns
`number`
#### Inherited from
[McDbObject](2d.McDbObject.md).[getDatabaseIndexId](2d.McDbObject.md#getdatabaseindexid)
___
### getExtensionDictionary
▸ **getExtensionDictionary**(): [`McDbDictionary`](2d.McDbDictionary.md)
得到对象的扩展字典数据.
#### Returns
[`McDbDictionary`](2d.McDbDictionary.md)
扩展字典数据
#### Inherited from
[McDbObject](2d.McDbObject.md).[getExtensionDictionary](2d.McDbObject.md#getextensiondictionary)
___
### getGripEditBasePointsIndex
▸ **getGripEditBasePointsIndex**(): `number`[]
获取对象的夹点对应的编辑基点索引。
#### Returns
`number`[]
#### Inherited from
[McDbObject](2d.McDbObject.md).[getGripEditBasePointsIndex](2d.McDbObject.md#getgripeditbasepointsindex)
___
### getGripPoints
▸ **getGripPoints**(): [`McGePoint3dArray`](2d.McGePoint3dArray.md)
获取对象的夹点数组
#### Returns
[`McGePoint3dArray`](2d.McGePoint3dArray.md)
#### Inherited from
[McDbObject](2d.McDbObject.md).[getGripPoints](2d.McDbObject.md#getgrippoints)
___
### getHandle
▸ **getHandle**(): `string`
得到对象句柄
#### Returns
`string`
返回对象句柄
#### Inherited from
[McDbObject](2d.McDbObject.md).[getHandle](2d.McDbObject.md#gethandle)
___
### getImp
▸ **getImp**(): `any`
获取内部实现对象。
#### Returns
`any`
内部实现对象。
#### Inherited from
[McDbObject](2d.McDbObject.md).[getImp](2d.McDbObject.md#getimp)
___
### getJson
▸ **getJson**(): `string`
获取 JSON 格式的字符串。
#### Returns
`string`
JSON 格式的字符串。
#### Inherited from
[McDbObject](2d.McDbObject.md).[getJson](2d.McDbObject.md#getjson)
___
### getObjectID
▸ **getObjectID**(): [`McObjectId`](2d.McObjectId.md)
获取对象 ID。
#### Returns
[`McObjectId`](2d.McObjectId.md)
对象 ID。
#### Inherited from
[McDbObject](2d.McDbObject.md).[getObjectID](2d.McDbObject.md#getobjectid)
___
### getOwnerID
▸ **getOwnerID**(): `number`
得到对象拥用者的id
#### Returns
`number`
#### Inherited from
[McDbObject](2d.McDbObject.md).[getOwnerID](2d.McDbObject.md#getownerid)
___
### has
▸ **has**(`sName`, `skipDeleted?`): `boolean`
检查找标注样式表中是否存在指定名称的找标注样式记录。
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `sName` | `string` | `undefined` | 找标注样式名称。 |
| `skipDeleted` | `boolean` | `true` | 是否跳过已删除找标注样式。 |
#### Returns
`boolean`
布尔值。
___
### initTempObject
▸ **initTempObject**(`imp`): `void`
初始化临时对象。
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `imp` | `any` | 内部实现对象。 |
#### Returns
`void`
#### Inherited from
[McDbObject](2d.McDbObject.md).[initTempObject](2d.McDbObject.md#inittempobject)
___
### isErased
▸ **isErased**(): `boolean`
对象是否已经删除
#### Returns
`boolean`
#### Inherited from
[McDbObject](2d.McDbObject.md).[isErased](2d.McDbObject.md#iserased)
___
### isHaveExtensionDictionary
▸ **isHaveExtensionDictionary**(): `boolean`
是否有扩展字典数据.
#### Returns
`boolean`
#### Inherited from
[McDbObject](2d.McDbObject.md).[isHaveExtensionDictionary](2d.McDbObject.md#ishaveextensiondictionary)
___
### isKindOf
▸ **isKindOf**(`sObjectName`): `boolean`
判断对象类型
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `sObjectName` | `string` | 类型名 |
#### Returns
`boolean`
返回对象是否是目标类型
#### Inherited from
[McDbObject](2d.McDbObject.md).[isKindOf](2d.McDbObject.md#iskindof)
___
### isNull
▸ **isNull**(): `any`
判断是否为空对象
#### Returns
`any`
#### Inherited from
[McDbObject](2d.McDbObject.md).[isNull](2d.McDbObject.md#isnull)
___
### moveGripPointsAt
▸ **moveGripPointsAt**(`iIndex`, `dXOffset`, `dYOffset`, `dZOffset`): `any`
移动对象的夹点
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `iIndex` | `number` | 索引 |
| `dXOffset` | `number` | X轴偏移量 |
| `dYOffset` | `number` | Y轴偏移量 |
| `dZOffset` | `number` | Z轴偏移量 |
#### Returns
`any`
#### Inherited from
[McDbObject](2d.McDbObject.md).[moveGripPointsAt](2d.McDbObject.md#movegrippointsat)
___
### setJson
▸ **setJson**(`str`): `boolean`
设置 JSON 格式的字符串。
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `str` | `string` | JSON 格式的字符串。 |
#### Returns
`boolean`
是否设置成功。
#### Inherited from
[McDbObject](2d.McDbObject.md).[setJson](2d.McDbObject.md#setjson)
___
### unErase
▸ **unErase**(): `boolean`
反删除对象。
#### Returns
`boolean`
#### Inherited from
[McDbObject](2d.McDbObject.md).[unErase](2d.McDbObject.md#unerase)