Skip to main content
12-Amethyst
March 27, 2024
Solved

How to handle master object creation while creating multiple versions of an object

  • March 27, 2024
  • 2 replies
  • 2764 views

I have a scenario,

consider I am creating the following objects using Windchill Custom API loader.

EPMDocument -

xyz.prt, versions A.1,B.1,C.1

WTPart - 

abc, versions A.1,B.1,C.1

I use the below static methods to initialize the objects.

EPMDocument.newEPMDocument(docNumber, docName, authoringApp, docType, cadName) for epmdocument

WTPart.newWTPart(number,name) for wtpart

 

My question:

First, when A.1 instance is created, i believe the API also creates its master object in the background.

What happens when i move to B.1 creation, with same API code?

will it attempt re-creation of master object (or)override  existing master object during B.1 and C.1?

 

 

 

 

Best answer by Fadel

@NP_10570407  try something like below to create a cad in a given version  :

*/
ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier("wt.epm.EPMDocument:169864");
EPMDocument epm = (EPMDocument) PersistenceHelper.manager.refresh(oid);

String version = "D";
MultilevelSeries mls = MultilevelSeries.newMultilevelSeries("wt.vc.VersionIdentifier", version);
VersionIdentifier vid = VersionIdentifier.newVersionIdentifier(mls);

WTKeyedHashMap rev_map = new WTKeyedHashMap();
ReviseOptions rev_opts = new ReviseOptions(epm);
// comment the line below if you want to use the next revision in the serie
rev_opts.document.versionId = vid;
rev_map.put( epm, rev_opts);
EPMDocumentHelper.service.reviseAll(rev_map);

 

2 replies

HelesicPetr
22-Sapphire II
22-Sapphire II
March 28, 2024

Hi @NP_10570407 

I would say test it, you will see.

Please can you also share the result of your test? That we can discus it. 

PetrH

PetrH
12-Amethyst
March 28, 2024

Hi @HelesicPetr ,

 

I have tested and end up with uniqueness exception as mentioned by @Fadel 

NP_10570407_0-1711631577827.png

 

Fadel
23-Emerald I
March 28, 2024

I would join Petr to test it , theoretically I would expect that you get 

wt.pom.UniquenessException: EPMDocument - xxxx is not unique

Buiꓘa
HelesicPetr
22-Sapphire II
22-Sapphire II
March 28, 2024

@Fadel 

And thanks that @NP_10570407 needs to find another way how to store new version to the system.

For example create a new revision on the existing object, with correct revision label etc.  

PetrH

PetrH
HelesicPetr
22-Sapphire II
22-Sapphire II
March 28, 2024

Hi @NP_10570407 

So if you load more revisions you have two options

 

First load all data from CSV and then check if there are different revisions and work with it.

 

Second you can react to the exception and try to revise the existing object to the revision you need by code and set the attributes from your CSV as you need.

 

PetrH

PetrH