windchill BOM复制api
时间: 2023-06-10 17:06:19 浏览: 104
Windchill提供了多种途径用于复制BOM,其中包括使用Windchill API实现复制。以下是一个Windchill BOM复制API的示例:
```java
public static WTPartUsageLink copyBOM(WTPartUsageLink usageLink, WTPart newPart) throws WTException {
// 获取原BOM信息
WTPartMaster originalMaster = (WTPartMaster)usageLink.getUses();
WTPart originalPart = (WTPart)WTPartHelper.service.getLatestIteration(originalMaster);
// 创建新的BOM信息
WTPartUsageLink newUsageLink = WTPartUsageLink.newWTPartUsageLink(newPart, originalPart, usageLink.getQuantity());
// 设置新的BOM属性
newUsageLink.setRoleAObject(usageLink.getRoleAObject());
newUsageLink.setRoleBObject(usageLink.getRoleBObject());
newUsageLink.setRoleAObjectDesc(usageLink.getRoleAObjectDesc());
newUsageLink.setRoleBObjectDesc(usageLink.getRoleBObjectDesc());
newUsageLink.setComponentLocation(usageLink.getComponentLocation());
newUsageLink.setComponentQuantity(usageLink.getComponentQuantity());
newUsageLink.setComponentRemarks(usageLink.getComponentRemarks());
// 复制BOM中的子件
QueryResult qr = WTPartHelper.service.getUsesOccurrences(originalPart);
while (qr.hasMoreElements()) {
WTPartUsageLink childUsageLink = (WTPartUsageLink)qr.nextElement();
copyBOM(childUsageLink, newPart);
}
// 保存新BOM信息
PersistenceHelper.manager.save(newUsageLink);
return newUsageLink;
}
```
该API的功能是复制一个WTPartUsageLink对象,包括其所有子级BOM信息。调用该API时,需要传入要复制的WTPartUsageLink对象和新创建的WTPart对象。
阅读全文