How to retrieve drawing that references an EPMDocument from Java?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How to retrieve drawing that references an EPMDocument from Java?
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.