mxcad_2d API 文档 / 2d / McDbLinetypeTable
Class: McDbLinetypeTable
2d.McDbLinetypeTable
McDbLinetypeTable 是数据库中的线型表,用于管理当前图纸中的所有线型定义。
Description
该类用于维护和访问图纸中的线型集合,包括获取线型记录、添加新线型、按名称定位线型等操作。 通过它可以完成:
- 获取全部线型记录 ID;
- 添加新的线型记录;
- 根据名称查找线型;
- 判断线型是否存在;
- 后续通过 McObjectId 获取真实的 McDbLinetypeTableRecord 进行编辑。
使用方式:
- 从数据库中获取当前线型表
MxCpp.getCurrentMxCAD().getDatabase().getLinetypeTable(); - 调用 getAllRecordId() 查看线型列表;
- 使用 add() / get() / has() 进行管理;
- 对返回记录对象设置线型名称和属性。
总结:在实际开发中,McDbLinetypeTable 是CAD线型管理的入口,适用于线型定义、线型选择和样式控制等场景。
Example
// 获取所有线型
import { MxCpp, McDbLinetypeTable } from "mxcad"
// 获取当前CAD对象
let mxcad = MxCpp.getCurrentMxCAD();
// 获取数据库线型表
let linetypeTable: McDbLinetypeTable = mxcad.getDatabase().getLinetypeTable();
// 获取线性表中的所有线型表记录对象ID
let aryId = linetypeTable.getAllRecordId();
// 遍历线型表记录对象
aryId.forEach((id) => {
let linetypeRec = id.getMcDbLinetypeTableRecord();
if (linetypeRec === null) return;
console.log(linetypeRec);
console.log("linetypeRec.name:" + linetypeRec.name);
});Hierarchy
↳
McDbLinetypeTable
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 McDbLinetypeTable(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 | McDbLinetypeTableRecord | 线型表记录对象。 |
Returns
新增线型记录对象ID。
Example
import { MxCpp, McDbLinetypeTable } from "mxcad";
let mxcad = MxCpp.getCurrentMxCAD();
let linetypeTable: McDbLinetypeTable = mxcad.getDatabase().getLinetypeTable();
let newLinetypeRecord = new McDbLinetypeTableRecord();
const id = linetypeTable.add(newLinetypeRecord);
console.log(id)assertObjectModification
▸ assertObjectModification(autoUndo?): number
设置对象被改变的状态,可自动触发更新显示函数,更新显示。 比如块表记录更新了,需要通知块引用更新显示,可以调用该函数。
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
autoUndo | boolean | false | 这次修改是否要自动支持撤销,默认为false |
Returns
number
Inherited from
McDbObject.assertObjectModification
clone
▸ clone(): null | McDbObject
克隆对象。
Returns
null | McDbObject
克隆出的对象。
Inherited from
createExtensionDictionary
▸ createExtensionDictionary(): boolean
创建对象的扩展字典数据.
Returns
boolean
Inherited from
McDbObject.createExtensionDictionary
erase
▸ erase(): boolean
删除对象。
Returns
boolean
是否删除成功。
Inherited from
get
▸ get(sName, skipDeleted?): McObjectId
查找线型表中的线型记录。
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
sName | string | undefined | 线型名称。 |
skipDeleted | boolean | true | 是否跳过已删除线型。 |
Returns
线型记录对象ID。
getAllRecordId
▸ getAllRecordId(skipDeleted?): McObjectId[]
获取线型表中的所有线型记录的ID。
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
skipDeleted | boolean | true | 是否跳过已删除线型。 |
Returns
ret 线型ID数组。
getDatabase
▸ getDatabase(): McDbDatabase
得到对象所在的数据库
Returns
返回数据库
Inherited from
getDatabaseIndexId
▸ getDatabaseIndexId(): number
获取对象的索引ID
Returns
number
Inherited from
getExtensionDictionary
▸ getExtensionDictionary(): McDbDictionary
得到对象的扩展字典数据.
Returns
扩展字典数据
Inherited from
McDbObject.getExtensionDictionary
getGripEditBasePointsIndex
▸ getGripEditBasePointsIndex(): number[]
获取对象的夹点对应的编辑基点索引。
Returns
number[]
Inherited from
McDbObject.getGripEditBasePointsIndex
getGripPoints
▸ getGripPoints(): McGePoint3dArray
获取对象的夹点数组
Returns
Inherited from
getHandle
▸ getHandle(): string
得到对象句柄
Returns
string
返回对象句柄
Inherited from
getImp
▸ getImp(): any
获取内部实现对象。
Returns
any
内部实现对象。
Inherited from
getJson
▸ getJson(): string
获取 JSON 格式的字符串。
Returns
string
JSON 格式的字符串。
Inherited from
getObjectID
▸ getObjectID(): McObjectId
获取对象 ID。
Returns
对象 ID。
Inherited from
getOwnerID
▸ getOwnerID(): number
得到对象拥用者的id
Returns
number
Inherited from
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
isErased
▸ isErased(): boolean
对象是否已经删除
Returns
boolean
Inherited from
isHaveExtensionDictionary
▸ isHaveExtensionDictionary(): boolean
是否有扩展字典数据.
Returns
boolean
Inherited from
McDbObject.isHaveExtensionDictionary
isKindOf
▸ isKindOf(sObjectName): boolean
判断对象类型
Parameters
| Name | Type | Description |
|---|---|---|
sObjectName | string | 类型名 |
Returns
boolean
返回对象是否是目标类型
Inherited from
isNull
▸ isNull(): any
判断是否为空对象
Returns
any
Inherited from
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
setJson
▸ setJson(str): boolean
设置 JSON 格式的字符串。
Parameters
| Name | Type | Description |
|---|---|---|
str | string | JSON 格式的字符串。 |
Returns
boolean
是否设置成功。
Inherited from
unErase
▸ unErase(): boolean
反删除对象。
Returns
boolean
