Hi All,
I want to fetch a Item List from Library context, which items are now used in different Product/Context in Windchill.
example,
1. Part A - Created in Stranded Library, now used in "TestASM A" which is present in context "TESTPRODUCT".
How i can get this Part A - Its Orignal Context i.e. Stranded Library, now used in "TestASM A" and its respective context i.e. "TESTPRODUCT".
how i can achive this through QML/query/or java code.
Any help will be great.
Regards,
Vivek
Hi Vivek,
You can query parts from library one by one and check all the assemblies where it is used using PersistenceHelper.manager.navigate. Following example should help, let me know if his is useful.
package ext;
import wt.fc.ObjectIdentifier;
import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.part.WTPart;
import wt.part.WTPartUsageLink;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
public class TestClass{
public static void main(String[] args) throws WTException, WTPropertyVetoException, InterruptedException {
ObjectIdentifier oid= ObjectIdentifier.newObjectIdentifier("wt.part.WTPart:281247");
WTPart parentprt= (WTPart) PersistenceHelper.manager.refresh(oid);
QueryResult links = PersistenceHelper.manager.navigate((Persistable)parentprt.getMaster(), WTPartUsageLink.USED_BY_ROLE, WTPartUsageLink.class, false );
while (links.hasMoreElements()) {
WTPartUsageLink object = (WTPartUsageLink) links.nextElement();
WTPart part =(WTPart)object.getRoleAObject();
System.out.println("Part " + parentprt.getNumber() +" is used in part "+ part.getNumber()+" located in "+ part.getContainerName());
}
}
}
Regards,
Bhushan