[返回博客](/cn/blog) # Teigha Mechanical 中 AmdtSystemAttribute 概述

Andrii Morozov 八月 17, 2017 [\#mechanical](/cn/blog/tag/mechanical) [\#getting started](/cn/blog/tag/getting-started)

<a class="a2a_button_facebook"></a><a class="a2a_button_twitter"></a><a class="a2a_button_linkedin"></a>

BOM（物料清单）管理器是一个服务类，用于处理 BOM 表、零件参考和 BOM 行。BOM 表持有的所有数据都存储在称为数据条目的数据容器中。数据条目有三种类型：DataEntry、DataEntryPart 和 DataEntryBlock。DataEntryPart 与零件参考相关联，DataEntryBlock 与组件相关联。

DataEntryPart 存储数据的方式与 DataEntryBlock 不同。BOM 管理器有一组方法提供对 BOM 表数据的访问，例如：

- getItemData 获取 BOM 行的数据；
- getPartData 获取零件参考的数据；

BOM 管理器方法可以获取附加到 DataEntryPart 的属性以及附加到 DataEntryBlock 的数据。DataEntryPart 将数据保存在一个普通数据数组中，而 DataEntryBlock 则采用不同的方法。

#### DataEntryBlock 结构特点

让我们看看 OdaMfcApp 中的一些 BOM 表（AcDbDictionary -&gt; AcmBOM）和一个 BOM 行（AcmBom -&gt; AcmBomRow）。

![image1](/files/inline-images/image001_8.png)BOM 行列表和选定行

这里我们可以看到 BomRow 条目属性的一部分。左侧是附加到 DataEntryBlock 的 BOM 行，右侧是附加到 DataEntryPart 的 BOM 行。基本上，通过组件定义对象隐式连接到 DataEntry 对象的特殊对象——AmdtSystemAttribute 对象中存储了附加到 DataEntryBlock（通过 BOM 行）的组件或零件的属性。

![image2](/files/inline-images/image002_2.png)BOM 行属性

DataEntryPart 将数据存储在普通数据序列（数组）中。DataEntryBlock 数据强烈依赖于组件定义 (CompDef) 对象。以下 DataEntryBlock 属性如下所示：

![image3](/files/inline-images/image003_3.png)DataEntryBlock 属性集

DataEntryBlock 持有指向 AcAmCompDef（组件定义）和组件名称的 SoftPointer。DataEntryBlock 与组件定义对象交互以获取其属性。

#### AmdtSystemAttributes 概述

AcAmCompDef 是一个组件定义对象，它描述了组件的整体。它包含组件对象、组件名称以及所选组件的视图定义对象。在 Teigha Mechanical 结构中，组件定义对象是 AmdtSystemAttribute 和 DataEntryBlock 对象之间的绑定元素。所有 AmdtSystemAttribute 对象都有一个全局持有者：AcRfMCADAPIAttHolder。

![image4](/files/inline-images/image004_2.png)AcRfMCADAPIAttHolder 内容

AcRfMCADAPIAttHolder 只是一个持有者，带有一组指向 AmdtSystemAttribute 对象的 HardPointer；AcRfMCADAPIAttHolder 不绑定任何东西。对于绑定，有 AcRfObjAttGroupMgr 对象。AcRfObjAttGroupMgr 将一组 AmdtSystemAttribute 和一个组件定义对象（AcAmCompDef 对象）绑定在一起。

![image5](/files/inline-images/image005_1.png)AcRfObjAttGroupMgr 内容

值得注意的是，AcRfObjAttGroupMgr 对象被聚合到一个全局的 AcRfAttGeneralMgr 中。

![image6](/files/inline-images/image006_0.png)AcRfAttGeneralMgr 内容

AmdtSystemAttribute 是所有 Teigha Mechanical 结构中最终的原子数据单元，用于保存属性数据。AmdtSystemAttribute 对象以 Unicode 格式保存属性名称和属性数据。

![image7](/files/inline-images/image007_1.png)AmdtSystemAttribute 内容

#### 代码示例

获取 AmdtSystemAttribute 值：

```
OdString AmdtSystemAttribute::getString() const;

```

获取 AmdtSystemAttribute 数组：

```
OdDbObjectIdArray AcRfObjAttGroupMgr::getSystemAttribIdArray() const;

```

通过 AcMeScope 获取 AcRfMCADAPIAttHolder：

```
void AcRfMCADAPIAttHolder::getHolderFromScope(const AcMeScope* pScope, OdDbObjectId& objectId) const;

```

通过 AcMeScope 获取 AcRfAttGeneralMgr：

```
AcRfAttGeneralMgrPtr AcRfAttGeneralMgr::getManagerFromScope(const AcMeScope* pScope) const;

```

#### 结论

BOM 管理器是一项服务，允许您处理零件数据和组件数据。大多数数据存储在数据条目中。Teigha Mechanical 结构的组织方式是，DataEntryPart 条目将数据存储在自身内部，而 DataEntryBlock 条目将数据存储在与其他数据条目隐式连接的对象中。AmdtSystemAttributes 允许您以方便的方式存储属性值。

## 今天就开始行动

**免费试用 ODA 软件 60 天。  
无风险，无需信用卡。**

[免费试用](https://www.opendesign.com/cn/free-trial)
