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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

API to create a copy of EPM Document in workspace

RK_10318816
4-Participant

API to create a copy of EPM Document in workspace

I am using Windchill PDMLink Release 11.2 and Datecode with CPS 11.2.0.2

Is it possible to create a copy of EPM Document in Workspace through API?
(EPM document is already added to workspace through API.)

3 REPLIES 3


@RK_10318816 wrote:

I am using Windchill PDMLink Release 11.2 and Datecode with CPS 11.2.0.2

Is it possible to create a copy of EPM Document in Workspace through API?
(EPM document is already added to workspace through API.)


Have a look at EnterpriseHelper.service.newMultiObjectCopy(), EnterpriseHelper.service.saveMultiObjectCopy, EnterpriseHelper.service.newCopy(), and EnterpriseHelper.service.saveCopy().

https://www.ptc.com/en/support/article/cs59135

https://www.ptc.com/en/support/article/cs108185

 

Hello Jones,

 

I have used this below API as you mentioned, but this is copying the EPM document in the container folder.

EnterpriseHelper.service.saveCopy()

My requirement is to create a copy in workspace for temporary use.


@RK_10318816 wrote:

Hello Jones,

 

I have used this below API as you mentioned, but this is copying the EPM document in the container folder.

EnterpriseHelper.service.saveCopy()

My requirement is to create a copy in workspace for temporary use.


You have to do the following:

  • Add the source objects to the workspace: EPMWorkspaceHelper.manager.addToWorkspace()
  • Then set the copied models container and folder to the workspace
EPMWorkspace creoWorkspace = <a workspace>
EPMDocument sourceModel = <a cad model>
WTContainer workspaceContainer = creoWorkspace.getContainer();// used below to set copied model's container

// Add sources to workspace if needed
WTCollection missingSources = new WTArrayList();
missingSources.add(sourceModel);
EPMWorkspaceHelper.manager.addToWorkspace(creoWorkspace, missingSources);

// See https://community.ptc.com/t5/Windchill/Using-newMultiObjectCopy-to-copy-EPMDocuments/m-p/388102
EPMContextHelper.setApplication(EPMApplicationType.toEPMApplicationType("EPM"));

// do the copy
EPMDocument modelCopy = (EPMDocument) EnterpriseHelper.service.newCopy(sourceModel);

// Set container, folder, etc
modelCopy.setNumber(<newNumber>);
modelCopy.setCADName(<newCadName>);
modelCopy.setName(<newName>);
modelCopy.setContainer(workspaceContainer);
FolderHelper.assignLocation((FolderEntry) modelCopy, creoWorkspace.getFolder());
Top Tags