Skip to main content
1-Visitor
August 8, 2012
Solved

How to retrieve drawing that references an EPMDocument from Java?

  • August 8, 2012
  • 1 reply
  • 4417 views

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.

Best answer by ptc-242232

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

1 reply

1-Visitor
August 10, 2012

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

1-Visitor
August 14, 2012

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.