Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hi All,
Below code giving some error, how i can fix this and get WTPartsusesby
Thanks,
Vivek
try{
WTPart part = null;
wt.fc.QueryResult qr=wt.part.WTPartHelper.service.getUsesWTPartMasters(part);
if(qr.hasMoreElements()){
System.out.println(part.getNumber()+"----Has----Child---"+qr.size());
wt.part.WTPartMaster partMaster = (WTPartMaster)part.getMaster();
wt.fc.QueryResult qr_parents = wt.part.WTPartHelper.service.getUsedByWTParts(partMaster);
while(qr_parents.hasMoreElements()) {
wt.part.WTPart parentPart = (wt.part.WTPart) qr_parents.nextElement();
System.out.println(partMaster.getNumber()+"----Has----Parents---"+parentPart.getName());
wt.part.WTPartMaster parentMaster = (WTPartMaster)parentPart.getMaster();
wt.fc.QueryResult qr_grandpa = wt.part.WTPartHelper.service.getUsedByWTParts(parentMaster);
}
}
}
Hi Vivek,
What kind of error you are getting ?
This is the first three line of your code.
"
try{
WTPart part = null;
wt.fc.QueryResult qr=wt.part.WTPartHelper.service.getUsesWTPartMasters(part);
"
in line no 2 you set part variable to null and without Instantiate it properly ,in line no 3 you are calling getUsesWTPartMaster() and passing part as an argumnet.
So i guess it will throw NullPointerException.
Others part of that code looks good.
thanks and regards,
Kaushik