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

How To find all "0" Level Parts from Windchill

SOLVED
Highlighted
Granite

How To find all "0" Level Parts from Windchill

Hi all,

I am Exporting Multilevel BOM from Windchill by API.. it Works..

now i want to export all BOM's present in Whindchill, so first i need to be find out the "0" Level Items from Windchill.

Plese let me know how i can do this ?

How i can find the TOP_LEVEl Parts from Windchill..

Thanks,

Vivek

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How To find all "0" Level Parts from Windchill

Hi,

In this line QueryResult rs = WTPartHelper.service.getUsesWTPartMasters(part); you are passing the part variable value as null which is leading to error.

Thanks and Regards,

Kaushik

6 REPLIES 6

Re: How To find all "0" Level Parts from Windchill

Hi Vivek,

you can use queryspec to querying the database to get all the end items

Re: How To find all "0" Level Parts from Windchill

If you use "End Item" to track top level assemblies , you can query the DB as Kaushik said.

if not , you have to query all WTPartsMasters, where the oid (ida2a2) does not exist is the WTPartUsageLink table (ida3b5). ie WTpart that are not used as child in a BOM.

You can do that query by API

Re: How To find all "0" Level Parts from Windchill

Hi All,

I found a new way by using partUsageLink to find the TOP level parts from asm, but the code gives some error,

Please can you help me to sort out issu.

Code is:

WTPart part = null;

QueryResult rs = WTPartHelper.service.getUsesWTPartMasters(part);

while(rs.hasMoreElements()){

System.out.println(""+rs.size());

System.out.println(part.getNumber()+"----Has----Child---"+rs.size());

WTPartMaster partMaster=(WTPartMaster)part.getMaster();

QueryResult qr_parents=WTPartHelper.service.getUsedByWTParts(partMaster);

while(qr_parents.hasMoreElements()){

WTPart parentPart = (WTPart)qr_parents.nextElement();

System.out.println(partMaster.getNumber()+"----Has----Parents---"+parentPart.getName());

partMaster =(WTPartMaster)parentPart.getMaster();

}

}

Re: How To find all "0" Level Parts from Windchill

Hi,

In this line QueryResult rs = WTPartHelper.service.getUsesWTPartMasters(part); you are passing the part variable value as null which is leading to error.

Thanks and Regards,

Kaushik

Re: How To find all "0" Level Parts from Windchill

Hi Kaushik,

Thanks for your reply,

I need some more help from you, if u don't mine.

I want to create a very Simple WTPart and WTDocument by using Windchill API,

for that i raise a query to PTC tech support but unfortunatly i not gting any code from them,

can you share the very simple code to create WTPart nad WTDocument ?

Thanks,

Vivek

Re: How To find all "0" Level Parts from Windchill

Hi Vivek,

The basic code to create WTPart.

WTPart part = WTPart.

newWTPart(“Myname”,”MyNumber”);

try {

part.setContainer(container);

Persistable persistable = PersistenceHelper.

manager.save(part);

}

catch (WTPropertyVetoException e) {

//

TODO

Auto-generated catch block

e.printStackTrace();

}

{

you can also use the code in workflow.

For document use WTDocument.

If you want to create Subtype if WTPart.

use

part.setTypeDefinitionReference(TypedUtilityServiceHelper.service.getTypeDefinitionReference("wt.part.WTPart|com.ptc.ElectricalPart"));

See the various methods in LoadPart and LoadDoc class for better understanding.

Thanks and Regards

Kaushik