How to Pack/Unpack BoM
CreateBOMWindowsResponse createBOMWindowsResponse = createBOMWindows2(modObjParent);
BOMWindow[] bomWindows = getBOMWindows(createBOMWindowsResponse);
BOMLine parentBOMLine = getParentBOMLine(createBOMWindowsResponse);
List<BOMLine> arrChildBOMLines = getChildren(parentBOMLine, plugin);
System.out.println( "Children BOMLines : " + arrChildBOMLines);
//Expand child lines one by one.
if(arrChildBOMLines != null && arrChildBOMLines.size() > 0)
{
for (int cnt = 0; cnt < arrChildBOMLines.size(); cnt++)
{
if(arrChildBOMLines.get(cnt) instanceof BOMLine)
{
//Get child bomlines
BOMLine bline = (BOMLine)arrChildBOMLines.get(cnt);
boolean bIsBomLinePacked = false;
try {
bIsBomLinePacked = bline.get_bl_is_packed();
}
catch (NotLoadedException e)
{
System.out.println("get_bl_is_packed attribute not loaded fetching from Tc="+ e);
bIsBomLinePacked = (Boolean) plugin.getObjectAttribute(bline,"bl_is_packed", null);
}
System.out.println("Value for get_bl_is_packed : " + bIsBomLinePacked);
if(bIsBomLinePacked)
{
System.out.println("BOM Line is packed, unpacking the complete BOMLine");
//com.teamcenter.services.strong.structuremanagement.StructureService
StructureService strucService = StructureService.getService(connection);
ServiceData response = strucService.packOrUnpack(new BOMLine[] { bline } , 3);
if(response.sizeOfPartialErrors() == 0)
System.out.println("unpacking successfull ");
}
}
}
}
Explanation :
StructureService strucService = StructureService.getService(connection);
ServiceData response = strucService.packOrUnpack(new BOMLine[] { bline } , 3);
packOrUnpack method parameters are ->1st Parameter) lines - The lines that need to be packed. If pack all option is selected, the children of the lines will be packed.2nd Parameter)flag - 0:pack the lines 1:unpack the lines 2:pack all lines 3:unpack all lines
本文详细介绍了如何使用StructureService的packOrUnpack方法来打包和解包BOM线,包括获取BOM线状态、判断是否已打包及进行相应操作的完整流程。通过示例代码展示了如何遍历子BOM线并根据其状态执行打包或解包操作。
1938

被折叠的 条评论
为什么被折叠?



