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
Hi,
I would want to get all the parts from a Drawing EPMDocument from code. Between the part and the drawing there is only a calculated link. But I need all parts (calculated,content...) which are related to the EPMDocument in any way. Is there a helper class that gives me back these links? If not, what are the APIs that I can use to get the 3D models linked to the Drawing, so that I can get the Parts from those?
What I used is: GenericUtilities.getAssociated(document);
This won't give me back the calculated links.
Thanks in advance,
Tamás
Hello @TamasBiro,
May be you can give it a try:
CadCollectedResult ccr = CadCollector.newInstance(seeds, navCriteria).dependents(GatherDependents.ALL).collect();
Thanks,
Shirish
Hi Tamás,
I've done this in the past by constructing a QuerySpec to search for EPMBuildRule objects. In this example the variable
drw
is an EPMDocument (in this case a CAD Drawing). The EPMBuildRule has a method called
getBuildType()
This returns an integer that describes the type of link you are navigating (see the code comments for more info). In my example this will return a WTPart if there is a Contributing Content Link between the given EPMDocument and the WTPart.
QuerySpec qs1 = new QuerySpec(EPMBuildRule.class);
Long objectId = drw.getBranchIdentifier();
qs1.appendWhere(new SearchCondition(EPMBuildRule.class, "roleAObjectRef.key.branchId", SearchCondition.EQUAL, objectId),INDEX);
QueryResult buildRules = PersistenceHelper.manager.find((StatementSpec) qs1);
// Search the CAD Drawing for Contributing Content links and return the linked // WTPart if its number matches the drawing number
while (buildRules.hasMoreElements()) {
EPMBuildRule buildRule = (EPMBuildRule) buildRules.nextElement();
/*
* Determine the type of link between the CAD Model and the WTPart
* 7: Owner link
* 4: Image link
* 6: Contributing Image link
* 2: Contributing Content link
*/
int buildType = buildRule.getBuildType();
if (buildType == 2) {
part = (WTPart) buildRule.getBuildTarget();
}
}
