Quantcast
Channel: PTC Community : Unanswered Discussions - Windchill
Viewing all articles
Browse latest Browse all 3592

check if EPMDoc has owner link to WTPart using API

$
0
0

Hi,

 

currently putting together a custom data utility, and as part of the this I need to check if an EPMDocument has 'owner' link to a WTPart, or alternatively find the EPMDocument which has 'owner' link .

 

I have tried the following:

  • to get all associated objects from the WTPart:
    • QueryResult cadDocs = WTPartHelper.service.getDescribedByDocuments(part)
  • to get active associated part from a EPMDoc:
    • AssociatedUtilities.getActiveAssociatedPart(cadDoc)
  • then tried to compare to see if the returned WTPart matched my starting WTPart.
    • if (AssociatedUtilities.getActiveAssociatedPart(cadDoc).equals(part)){......

 

However this does not always return the result I expect. If I have 2 EPMDocs associated, and 1 has 'owner' link then great - it works. If I then change that association of the first EPMDoc so that it has link 'content' rather than 'owner' and the second EPMDoc has link 'contributing content', then it return the second EPMDoc. If I then modify the association again to return the first EPMDoc to link type 'owner', it still returns the second EPMDoc which has link type 'contributing content'.

 

Hopefully that all makes sense?

 

If so, any ideas what I may be doing wrong?

 

the entire method I have been using to check for each associated EPMDOc is:

 

private EPMDocument getCadDoc(WTPart part) throws WTException {
  EPMDocument cadDoc = null;

  QueryResult cadDocs = WTPartHelper.service
    .getDescribedByDocuments(part);

  while (cadDocs.hasMoreElements()) {
   WTObject obj = (WTObject) cadDocs.nextElement();
   if (obj instanceof EPMDocument) {
    cadDoc = (EPMDocument) obj;
    if (AssociateUtilities.getActiveAssociatedPart(cadDoc).equals(
      part)) {
     break;
    } else {
     cadDoc = null;
    }
   }
   cadDoc = null;
  }
  return cadDoc;

}

 

Using WC 10.1 M040.

 

Cheers

 

 

 





Viewing all articles
Browse latest Browse all 3592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>