使用案例 15:根據零件屬性 (相同類型、多個組態) 產生下游結構
請考慮這樣一種情境:即 BOM 轉換器中存在以下結構:
• 下游結構不存在。
• 上游結構中的零件屬於 WTPart 的不同子類型。
• PartSubType1、PartSubType2 與 PartSubType3 是 WTPart 的子類型。
PartSubType3_1 是 PartSubType3 的子類型。
欲根據具有相同類型及多個組態的零件屬性產生下游結構,您可以使用規則檔案或內容檔案來指定轉換與重新建構規則。
使用規則檔案
在文字檔案中,新增 JSON 格式的下列規則:
{
"transformRules": [
{
"sourceType": "wt.part.WTPart",
"sourceAttributes": ["AUA=yes"],
"targetType": "wt.part.WTPart",
"transformOption": "addSame"
},
{
"sourceType": "wt.part.WTPart",
"targetType": "wt.part.WTPart",
"transformOption": "newBranch"
},
{
"sourceType": "org.rnd.PartSubType3",
"doNotTransform": "true"
},
{
"sourceType": "org.rnd.PartSubType2",
"doNotTransform": "true"
}
]
}
使用內容檔案
1. 存取位於 Windchill/codebase/com/ptc/core/foundation/associativity 中的 associativity.properties.xconf 檔案。
2. 新增下列重新建構規則:
<Property name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule1" multivalued="," default=""/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule1" value="attribute.AUA=yes"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule1" value="transformOption=addSame"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule1" value="targetType=wt.part.WTPart"/>
<Property name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule2" multivalued="," default=""/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule2" value="transformOption=newBranch"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart.rule2" value="targetType=wt.part.WTPart"/>
<Property name="com.ptc.windchill.associativity.reconciliation.addusage.org.rnd.PartSubType2.rule1" multivalued="," default=""/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.org.rnd.PartSubType2.rule1" value="doNotTransform=true"/>
<Property name="com.ptc.windchill.associativity.reconciliation.addusage.org.rnd.PartSubType3.rule1" multivalued="," default=""/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.org.rnd.PartSubType3.rule1" value="doNotTransform=true"/>
執行「產生下游結構」動作之後,下列結構會顯示在「BOM 轉換器」中:
根據在規則檔案或內容檔案中指定的條件,會以下列方式產生下游結構:
• Part1 (Design)、Part2 (Design)、Part3 (Design) 與 Part4 (Design) 的類型為 WTPart,屬性 AUA 為 Yes。它們會依原樣新增到各自零件下。
• 類型為 WTPart 的 SubType1_Assembly (Design)、PartType_Assembly (Design) 與 Sub_Assembly1 (Design) 的屬性 AUA 不會是 Yes。因此,會將它們新增為各自零件下的新分支。
• 不會轉換類型為 PartSubType3 的 PartSubType3_Assm1(Design) 與類型為 PartSubType2 的 PartSubType2_Assembly1 (Design)、PartSubType2_Assembly2 (Design)。
• 也不會轉換 PartSubType3_1_Assembly1,因為其類型為子類型為 PartSubType3 的 PartSubType3_1。