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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

I need to retrive the Part from the BOM structure which are not having CAD Association.

AR_9920456
14-Alexandrite

I need to retrive the Part from the BOM structure which are not having CAD Association.

"I need to retrieve the parts from the BOM structure that do not have a CAD association. Once identified, I want to associate an empty CAD assembly with each of these parts. The CAD association for each part should be named based on the respective part."

12 REPLIES 12

Hi @AR_9920456 

If you need to find parts that do not have CAD from one BOM use the compare function "Compare to CAD Structure" from part detail page action menu.

HelesicPetr_0-1709884802195.png

 

Another way is to create a QureyBuilder report in the Windchill Report Management

The QueryBuilder report can be used in Advanced search and there you can interact with the result objects.  

here is a report how to search EPM Document without WTP but you can change the direction...

CS390356 - How to create Query Builder Report to find "EPM Document" which is not associated with a "WTPart" in Windchill PDMLink

also you can use a one level report together

CS72503 - Report to get the bill of material (BOM) report for latest iteration of latest version in Windchill PDMLink

 

report technique

Windchill Reporting Resource

 

an Another way is to write own code to report what you need 😄

 

PetrH

AR_9920456
14-Alexandrite
(To:HelesicPetr)

any sample code to retrieve the parts which has not having CAD association

Hi @AR_9920456 

If you want to write a code, then don't care about retrieving what does not have a association.

get the full BOM and go through the bom and check if the association exists.

code to get owner association is 

 

QueryResult activeEMPDoc = PersistenceHelper.manager.navigate(sourceWTPart, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class);

 

if the result is null or zero(empty) then the association does not exists

 

PetrH

AR_9920456
14-Alexandrite
(To:HelesicPetr)

Thank You,

I have a requirement that from the variants Structure we don't have cad association i need to iterate through each level and check for the CAD association if their no association, their is empty cad assembly we need to associate that cad to each part and saveas the cad name based on the respective part number

 

HI@AR_9920456 

Do you know how to create EPMDocument by code? 

PetrH

AR_9920456
14-Alexandrite
(To:HelesicPetr)

I don't want to create an EPM Document. An empty assembly named "empty.SLDASM" has already been created. I need to associate this assembly with variants that do not have CAD associations. The CAD name should be changed to the respective variant's number and associated with the respective variant.

Hi @AR_9920456 

You have to describe what object you want to link in better way. Screenshot could be more helpful or any picture of your idea. 

the API that helps to recognize if the WTPart has owner link to cad I've already provided.

PetrH 

AR_9920456
14-Alexandrite
(To:HelesicPetr)

This is the code that i have return, I want to retrieve the parts which is not associate to the EPM Document.

 

public class SaveasUtilityFormProcessor extends DefaultObjectFormProcessor {

public FormResult doOperation(NmCommandBean nmCommandBean, List<ObjectBean> listOfObjects) throws WTException {

FormResult formResult = new FormResult();

String warningMsg = null;

Object object = nmCommandBean.getActionOid().getRefObject();

System.out.println("object: " + object);

 

if (object instanceof WTPart) {

WTPart part = (WTPart) object;

 

// Check if the parent part has a CAD association

QueryResult parentEMPDoc = PersistenceHelper.manager.navigate(part, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class);

 

if (parentEMPDoc == null || !parentEMPDoc.hasMoreElements()) {

System.out.println("Parent part " + part.getName() + part.getNumber() + " does not have an associated EPM document.");

// You can add further logic here if needed

} else {

// Print the details of the associated parent EPM documents if needed

while (parentEMPDoc.hasMoreElements()) {

// You can add logic to print the details of associated parent EPM documents here

}

}

 

// Get the part usage links of the part

QueryResult partUsageLinks = WTPartHelper.service.getUsesWTPartMasters(part);

 

// Iterate through the part usage links

while (partUsageLinks.hasMoreElements()) {

WTPartUsageLink usageLink = (WTPartUsageLink) partUsageLinks.nextElement();

WTPartMaster childPart = (WTPartMaster) usageLink.getUses();

 

// Navigate from the child part to EPM documents using EPMBuildRule

QueryResult activeEMPDoc = PersistenceHelper.manager.navigate(childPart, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class);

 

// Check if the result is null or empty

if (activeEMPDoc == null || !activeEMPDoc.hasMoreElements()) {

System.out.println("Child part " + childPart.getName() + childPart.getNumber() + " does not have an associated EPM document.");

// You can add further logic here if needed

} else {

// Print the details of the associated EPM documents if needed

while (activeEMPDoc.hasMoreElements()) {

// You can add logic to print the details of associated EPM documents here

}

}

}

}

 

return formResult;

}

}





Hi @AR_9920456 

If you control the structure objects you need to find latest iteteration, you can not use master objects in the method

QueryResult activeEMPDoc = PersistenceHelper.manager.navigate(childPart, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class);

You always has to use WTPart object ton Master one. 

So variable has to be WTPart childPart....

You have to use Master to get the latest iteration. 

 

PetrH

AR_9920456
14-Alexandrite
(To:HelesicPetr)

can you please show me how to do this. 

AR_9920456
14-Alexandrite
(To:AR_9920456)

I have done as same as you suggested now i am getting the parts which are not having the cad association. now i need to associate the one empty cad assembly to that part . 

Hi @AR_9920456 

Here is a method to create the link between an EPM and a WTP

 

//EPMDocument epmDocAssoc, WTPart partAssoc, int buildType (EPMBuildRule.ALL_BUILD_ROLES)
epmbuildrule = EPMBuildRule.newEPMBuildRule(epmDocAssoc, partAssoc, buildType);
epmbuildrule = (EPMBuildRule) PersistenceHelper.manager.save(epmbuildrule);

 

 PetrH

Announcements

Top Tags