Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello,
my question is related to Windchill Java API and Windchill 10.1 M010.
There is a Creo part (PRT file) and its drawing (DRW file) in my Windchill database.
I am able to find the part (EPMDocument) in my Java application.
Now, I need to find the drawing my part is referenced by.
I tried various methods from wt.vc.struct.StructService, but I always got an empty result
(empty QueryResult or empty WTKeyedMap).
Does anyone know how to find drawing references using Java API?
Thanks in advance
mp.
Solved! Go to Solution.
Michal,
Try this
public static EPMDocument getDrawingModel(EPMDocument model) throws WTException {
EPMDocument drawing = null;
QueryResult qr = EPMStructureHelper.service.navigateReferencedBy((EPMDocumentMaster) model.getMaster(), null, false);
while (qr.hasMoreElements()) { //These are the links
System.out.println(qr.nextElement().getClass().getName());
}
qr = EPMStructureHelper.service.navigateReferencedBy((EPMDocumentMaster) model.getMaster(), null, true);
while (qr.hasMoreElements()) { //These are the drawings
drawing = (EPMDocument) qr.nextElement();
System.out.println(drawing.getIdentity() + "." + drawing.getIterationIdentifier().getValue());
}
return drawing;
}
Hope this help,
David
Michal,
Try this
public static EPMDocument getDrawingModel(EPMDocument model) throws WTException {
EPMDocument drawing = null;
QueryResult qr = EPMStructureHelper.service.navigateReferencedBy((EPMDocumentMaster) model.getMaster(), null, false);
while (qr.hasMoreElements()) { //These are the links
System.out.println(qr.nextElement().getClass().getName());
}
qr = EPMStructureHelper.service.navigateReferencedBy((EPMDocumentMaster) model.getMaster(), null, true);
while (qr.hasMoreElements()) { //These are the drawings
drawing = (EPMDocument) qr.nextElement();
System.out.println(drawing.getIdentity() + "." + drawing.getIterationIdentifier().getValue());
}
return drawing;
}
Hope this help,
David
Hello David,
thank you for your post.
Your code works fine.
In the meantime, my colleague found another way using PersistenceManager (see below),
but your solution seems more appropriate.
QueryResult tst = PersistenceHelper.manager.navigate(doc.getMaster(), EPMReferenceLink.REFERENCED_BY_ROLE, EPMReferenceLink.class, false);
mp.