I need to get all the child nodes(CAD Parts) in a CAD assembly(.asm) as a list so that I can set the state of each of those child parts.
You can use this
public static Collection<EPMDocument> getChildParts (EPMDocument epm) {
Collection<EPMDocument> theCollection = new ArrayList<EPMDocument>();
Collection<EPMDocument> drwCollection = new ArrayList<EPMDocument>();
logger.debug("getChildParts:" + "recieved part number " + epm.getNumber() + " " +epm.getIterationDisplayIdentifier());
try {
QueryResult qr = EPMStructureHelper.service.navigateUses(epm, null, false);
logger.debug("getChildParts:" + " Number of usage links found " + qr.size());
while(qr.hasMoreElements()) {
EPMMemberLink epmMemberLink = (EPMMemberLink) qr.nextElement();
EPMDependencyMaster emasters = epmMemberLink.getUses();
QueryResult query = ConfigHelper.service.filteredIterationsOf(emasters, new LatestConfigSpec());
while(query.hasMoreElements()) {
EPMDocument temEpm = (EPMDocument)query.nextElement();
logger.debug("getChildParts:" + temEpm.getNumber()+ " " +temEpm.getIterationDisplayIdentifier());
if (!theCollection.contains(temEpm) && temEpm instanceof EPMDocument ) {
theCollection.add(temEpm);
drwCollection=getEPMReferencedByDrawing(temEpm);
Iterator iter =drwCollection.iterator();
while(iter.hasNext()) {
EPMDocument epmd = (EPMDocument)(iter.next());
if (!theCollection.contains(epmd)&& epmd instanceof EPMDocument) {
if(epmd instanceof EPMDocument){
theCollection.add(epmd);
}
}
}
}
}
}
}
catch(Exception e) {
}
return theCollection;
}
Hi Binesh,
thanks for your reply. Yes it does work.
in our snippet you mentioned the method drwCollection=getEPMReferencedByDrawing(temEpm); ,guess its an custom one.I do have requirement to requirement to fetch related CAD drawing also ..It will be great if you could provide any inputs on that.
Hello Hemadri,
Here is what I have for that method. Some of this methods are new iterations, still in development, please test it whether it fits your requirements
Collection<EPMDocument> theCollection = new ArrayList<EPMDocument>();
try {
logger.debug("getEPMReferencedByDrawing : Top: " + top.getNumber());
EPMDocumentMaster master = (EPMDocumentMaster)top.getMaster();
QueryResult referencedBy = EPMStructureHelper.service.navigateReferencedBy(master, null, false);
// LatestConfigSpec configSpec = new LatestConfigSpec();
// referencedBy = configSpec.process(referencedBy);
logger.debug("getEPMReferencedByDrawing :Drawings Found: " + referencedBy.size());
while (referencedBy.hasMoreElements()) {
EPMReferenceLink refLink = (EPMReferenceLink) referencedBy.nextElement();
logger.debug("getEPMReferencedByDrawing :: " + refLink.getReferencedBy().getName());
EPMDocument epmTemp = refLink.getReferencedBy();
QueryResult qr = wt.vc.config.ConfigHelper.service.filteredIterationsOf(epmTemp.getMaster(), new LatestConfigSpec());
while(qr.hasMoreElements()) {
epmTemp = (EPMDocument)qr.nextElement();
if (refLink.getReferenceType().toString().toLowerCase().equals("drawing") ) {
if(!theCollection.contains(epmTemp)) {
if(epmTemp instanceof EPMDocument){
theCollection.add(epmTemp);
}
logger.debug("Drawing found " + epmTemp.getIdentity() + " Link Details " + refLink.getReferenceType());;
}
}
}
}
}
catch(WTException e) {
e.printStackTrace();
}
return theCollection;
}