cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to retrieve drawing that references an EPMDocument from Java?

ptc-4428645
1-Visitor

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.

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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.

Announcements


Top Tags