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.

API to create Link between WTPart and EPMDocument

vuchekar
9-Granite

API to create Link between WTPart and EPMDocument

Hi All,

I am trying to create a Link between WTPart and EPMDocument objects by using below code,

it's executed without error but it not create any kind of link in between these two objects.

is any one tried to create Link between WTPart and EPMDoc.

Please review below code and suggest the correct way to create this type of links.

======================

  1. System.out.println("Getting the epmdocument");

EPMDocument source = getEPMDocument(); //getEPMDocument method returns me object of EPMDoc type

System.out.println("Getting the WTPart");

WTPart target = getWTPart(); // getWTpart method returns me object of WTPart type

System.out.println("Creating the link between wtpart and epmdocument");

int buildType = 1;

source = (EPMDocument) WorkInProgressHelper.service.checkout(source,WorkInProgressHelper.service.getCheckoutFolder(),"").getWorkingCopy();

EPMBuildRule link = EPMBuildRule.newEPMBuildRule(source, target);

PersistenceServerHelper.manager.insert(link);

System.out.println("Link has been created");

WorkInProgressHelper.service.checkin(source,null);

System.out.println("Done...");


================


Thanks,

Vivek

3 REPLIES 3
RandyJones
19-Tanzanite
(To:vuchekar)

Vivek: I have used the following to create a link between a wtpart and an empdocument drawing:


EPMDocument epmDoc = getEPMDocument(); //getEPMDocument method returns me object of EPMDoc type

WTPart wtPart= getWTPart(); // getWTpart method returns me object of WTPart type

Folder checkedout = WorkInProgressHelper.service.getCheckoutFolder();

WTPart wtPartWC = (WTPart) WorkInProgressHelper.service.checkout(wtPart, checkedout, "").getWorkingCopy();//checkout and get the working copy

/*

From https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS188209

wt.epm.build.EPMBuildRule.newEPMBuildRule(EPMDocument source, WTPart target, int buildType)

buildType parameter comes from the following:

1.         Owner Link : builtType = EPMBuildRule.BUILD_ATTRIBUTES | EPMBuildRule.BUILD_STRUCTURE | EPMBuildRule.CAD_REPRESENTATION;

2.         Image Link : builtType = EPMBuildRule.CAD_REPRESENTATION;

3.         Contributing Image Link : builtType = EPMBuildRule.BUILD_ATTRIBUTES | EPMBuildRule.CAD_REPRESENTATION;

4.         Contributing Content Link : builtType = EPMBuildRule.BUILD_ATTRIBUTES;

*/

EPMBuildRule buildRule = EPMBuildRule.newEPMBuildRule(epmDoc, wtPartWC, EPMBuildRule.BUILD_ATTRIBUTES);

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

WorkInProgressHelper.service.checkin(wtPartWC, "Associated the Drawing");

kchen
1-Newbie
(To:vuchekar)

Vivek, i think Randy is right. Please be informed that while a EPMDocument get associated with a WTPart, only the WTPart will get iterated. Hence we check out WTPart to associate them.

vuchekar
9-Granite
(To:kchen)

Hi Kavin,

Yes Randy was correct. i am able to cretae link between WTPart and EPMDocument after check out the WTPart.

Hi Randy,

Thanks for your help.

I have another question related to links, which type of link present between Assembly and it's drawing.

which Api i have to use to create link between assembly and it's drawing?

Any help will be grate.

Thanks,

Vivek

Top Tags