Skip to main content
17-Peridot
June 1, 2025
Solved

Get WTPart attribute for associated EPM model OR drawing

  • June 1, 2025
  • 2 replies
  • 1761 views

Version: Windchill 13.0

 

Use Case: Working on getting specific WTPart attributes overlaid on published drawing PDFs.


Description:

I thought this would be simple enough but I ended up struggling the last two days in trying to achieve the following:

  • Code collects and makes available an EPMDocument ID. βœ”️
    • EPMDocument could be either a drawing or a model and it will have an associated WTPart. 

If this is a drawing:

EPMStructureHelper.service.navigateReferences(etc etc)

instead... from here I can't resolve either the EPMReferenceLink IDs or the EPMDocumentMasters (depending on the boolean settings) to get the related model. 

 

It's not clear to me where to go to get the "rolename" values or "buildrule" integer values to be able to go directly from the drawing to the WTPart. That would be ideal. 

 

There's CS351622 that goes over how to fetch an owner linked WTPart. Assuming here that if I change "OWNER" to "IMAGE" or "CALCULATED" (?) this may give me what I want? 

 

I just feel like I'm missing some pretty important pages from some customization guide somewhere... 

Best answer by joe_morton

I think you'll have to split the code into two cases:

  • If the EPMDocument you start with is a model, it should be pretty straightforward to get the WTPart.
  • If the EPMDocument you start with is a drawing (with calculated link to WTPart), you'll have to navigate from drawing -> model master -> version of model you want (latest?) -> WTPart

From drawings, Windchill stores at least 3 types of links to other CAD files:

  • Drawing Reference - the model added directly to the drawing. This is the one you want, but there can be multiple of these!
  • Default - additional references (child components in an assembly, for example)
  • Drawing Format Reference

Not a full solution, but hope that helps point you in the right direction

 

Something you may want to consider as a shortcut would be if you have any numbering conventions for your models / drawings / WTParts. We, for instance, basically match the number on all three, so as long as things are numbered correctly (BIG IF), I could use the number from the first EPMDocument, then run a query to get the WTPart with the number that corresponds.

2 replies

18-Opal
June 2, 2025

What type of link are you using to link the WTPart and CAD drawing?

Image and Calculated?

Not Content?

Dobi17-PeridotAuthor
17-Peridot
June 2, 2025

Generally, the drawing will only ever be calculated. The model could be either image or owner but not content.

18-Opal
June 2, 2025

I meant is the drawing a Content link not the model. Regardless as long as we know it’s Calculated link that all we need to know.

 

Do you understand what a calculated link is?

Meaning how it is calculated?

13-Aquamarine
June 2, 2025

From your description, it seems you are looking to navigate the DescribedBy from a WTPart to an EPMDocument Drawing?
You might want to chceck:
- https://www.ptc.com/en/support/article/CS131357
- https://www.ptc.com/en/support/article/CS240504
- https://support.ptc.com/help/windchill/r13.1.0.0/en/#page/Windchill_Help_Center/ManagingCADandPartRelationships/MCPR_AssociationOview.html

This code snippet may help:
wt.fc.collections.WTCollection parts = new wt.fc.collections.WTArrayList();
parts.add(part);
wt.fc.collections.WTKeyedMap associatedCADDocumentMap = ((wt.part.StandardPartDocService)wt.part.PartDocHelper.service).getAssociatedCADDocuments(parts);

Dobi17-PeridotAuthor
17-Peridot
June 2, 2025

@MalteSiefkes 

I'm looking to navigate the opposite way: from an EPMDocument (either drawing or model) to a WTPart. 

 

So likely this may give me what I want:

com.ptc.windchill.collector.api.cad

getAssociatedParts(EPMDocument seed)

 

joe_morton
18-Opal
18-Opal
June 2, 2025

I think you'll have to split the code into two cases:

  • If the EPMDocument you start with is a model, it should be pretty straightforward to get the WTPart.
  • If the EPMDocument you start with is a drawing (with calculated link to WTPart), you'll have to navigate from drawing -> model master -> version of model you want (latest?) -> WTPart

From drawings, Windchill stores at least 3 types of links to other CAD files:

  • Drawing Reference - the model added directly to the drawing. This is the one you want, but there can be multiple of these!
  • Default - additional references (child components in an assembly, for example)
  • Drawing Format Reference

Not a full solution, but hope that helps point you in the right direction

 

Something you may want to consider as a shortcut would be if you have any numbering conventions for your models / drawings / WTParts. We, for instance, basically match the number on all three, so as long as things are numbered correctly (BIG IF), I could use the number from the first EPMDocument, then run a query to get the WTPart with the number that corresponds.