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

We are happy to announce the new Windchill Customization board! Learn more.

How to copy Representation of CAD Document to WTPart

nmala
4-Participant

How to copy Representation of CAD Document to WTPart

Hello All,

We have a requirement to copy Representation from CAD Document to its associated WTPart.

I want to do this through code because if I set preference Build Associated Parts to Yes it is creating Structure of the CAD Document on WTPart and this is not required.

I am trying this way and it is not working.

########################################################################

wtpart = (WTPart) factory.getReference("OR:wt.part.WTPart:414184331").getObject();

qr_new = PersistenceHelper.manager.navigate(wtpart, EPMBuildRule.BUILD_SOURCE_ROLE, EPMBuildRule.class,true);

if(qr_new.hasMoreElements())

{

epm = (EPMDocument) qr_new.nextElement();

Representation rep_pub = PublishUtils.getRepresentation(epm);

RepresentationHelper.service.storeRepresentation(rep_pub, wtpart, null, rep_pub.getDescription(), rep_pub.getRepresentationType());

PersistenceHelper.manager.refresh(wtpart);

}

########################################################################


Please let me know if any one has done copy of Representation from CAD Document to WTPart.

Thanks,

Niranjan M

1 ACCEPTED SOLUTION

Accepted Solutions
nmala
4-Participant
(To:nmala)

Representations are always stored on EPM Documents when there are no owner associations to a WTPart. If an EPM Document has an owner association to a WTPart, the representation is stored on the WTPart. In such a case, the EPM Document and the WTPart are related via an EPM Build History Link.

Created EPMBuildHistoryLink to have representation on WTPart.

EPMBuildRule buildRule = EPMBuildRule.newEPMBuildRule(epmdocument, wtpart_wrkingcopy);

buildRule = (EPMBuildRule)PersistenceHelper.manager.save(buildRule);

long l = buildRule.getUniqueID();

EPMBuildHistory epmbuildhistory = EPMBuildHistory.newEPMBuildHistory(epmdocument, wtpart_wrkingcopy, l);

PersistenceServerHelper.manager.insert(epmbuildhistory);

View solution in original post

1 REPLY 1
nmala
4-Participant
(To:nmala)

Representations are always stored on EPM Documents when there are no owner associations to a WTPart. If an EPM Document has an owner association to a WTPart, the representation is stored on the WTPart. In such a case, the EPM Document and the WTPart are related via an EPM Build History Link.

Created EPMBuildHistoryLink to have representation on WTPart.

EPMBuildRule buildRule = EPMBuildRule.newEPMBuildRule(epmdocument, wtpart_wrkingcopy);

buildRule = (EPMBuildRule)PersistenceHelper.manager.save(buildRule);

long l = buildRule.getUniqueID();

EPMBuildHistory epmbuildhistory = EPMBuildHistory.newEPMBuildHistory(epmdocument, wtpart_wrkingcopy, l);

PersistenceServerHelper.manager.insert(epmbuildhistory);

Top Tags