cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to get List of Items which created in Library Context, but now used in different Assembly's in Diffrent Context

vuchekar
10-Marble

How to get List of Items which created in Library Context, but now used in different Assembly's in Diffrent Context

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

1 REPLY 1

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

Announcements


Top Tags