Skip to main content
1-Visitor
Aug 8, 2012 8:54 AM UTC
Solved

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.

1-Visitor
Aug 10, 2012 12:06 AM UTC

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

2 replies

1-Visitor
Aug 10, 2012 12:06 AM UTC

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

Translate
1-Visitor
Aug 14, 2012 6:31 AM UTC

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.

Translate