Teamcenter中TCComponentItem与TCComponentBOMLine的创建

1:在teamcenter中创建零组件对象:直接上方法

       TCSession session = (TCSession) AIFUtility.getDefaultSession();  //获取tcsession

public TCComponentItem createItem(TCSession session, String type,String itemID, String itemName, String itemRev) throws TCException {

               //type是"Item",itemID是零组件id,itemName是零组件名字,itemRev是零组件版本

               TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);

                //根据零组件信息创建零组件对象

 

 

              TCComponentItem  item = itemType.create(itemID,intmRev, type, itemName, "", null);

 

 

//item = itemType.find(itemID);  //可以根据零组件id查询tc中有没有这个零组件对象

          }

 

2:在teamcenter中创建BOMLine对象:

     public TCComponentBOMLine addBOMLine(TCSession session,
TCComponentItem parentItem, TCComponentItem childrenItem) throws TCException {

               //prantItem是父零组件对象,childrenItem是子零组件对象
TCComponentBOMLine bomline = null;
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow window = winType.create(null);
window.lock();
TCComponentBOMLine topLine = window.setWindowTopLine(parentItem,parentItem.getLatestItemRevision(), null, null);
bomline = topLine.add(childrenItem,childrenItem.getLatestItemRevision(), null, false, "");
topLine.save();
window.save();
window.unlock();
window.close();
return bomline;
}

 

你可能感兴趣的:(Teamcenter开发)