Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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?
Solved! Go to Solution.
@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);
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
I would join Petr to test it , theoretically I would expect that you get
wt.pom.UniquenessException: EPMDocument - xxxx is not unique
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
@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);
@Fadel Thanks for sharing the code snippet. my scenario is different. I have to bulk load(create) objects based on input csv file. csv can have entries for more revisions/versions of same object. my method code below(sorry for long thread):
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
Thanks a ton to both @HelesicPetr and @Fadel for your valuable inputs. it helped me to resolve the uniqueness error.
You guys are great.
My loader read the input values from a csv file and create the epmdocuments accordingly.
In csv file, i have entries to create two revisions of same object back to back. for e.g.,
A.1 created successfully, while creating the same B.1 using same API, it fails with uniqueness