Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi,
We are trying to make an automatic numbering system for certain product folders. Ideally, we would like to have a prefix that reflects the product folder name and then a sequential number (auto generated).
Our current system involves us manually changing the prefix in the OIR. Is there any way to add the context as a prefix by editing the OIR file so that this is automatic for all products created? The current number generating script looks like:
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Arg>PROJ-EMR:ZHD-</Arg>
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:6:0}</Arg>
</AttrValue>
Thanks,
Hannah
Hi Hannah,
I am not sure whether It can be done using OOTB behaviour but you can write your own rule algorithm for that and call that rule alogirthm from your OIR.
package study.rule;
import wt.inf.container.WTContainer;
import wt.inf.container.WTContainerRef;
import wt.rule.algorithm.RuleAlgorithm;
import wt.util.WTException;
public class DateTime implements RuleAlgorithm
{
@Override
public Object calculate(Object[] arg0, WTContainerRef arg1)
throws WTException {
WTContainer contref = arg1.getReferencedContainer();
String cont = arg1.getReferencedContainer().getName();
return (Object)(cont);
}
}
Hi ,
Is it possible to add the folder name to the auto numbering.
Ex : product name : abc , sub folder name : ECAD
Document name as : abc-ECAD-auto generated number.
Trust me - you don't want to do this.
Hello,
our EPM-Document Rule allocates a number of the standard-numbergenerator and sets the name of the product as a prefix, but only when we create a new EPM-Document in the intern browser of Creo 2.0.
For example:
Product-Name = TESTPRODUCT
EPM-Document Number = TESTPRODUCT_0000000308
If a product name cannot be found, the prefix should be filled with 6 zeros.
For example:
no product name is found or no product name exists
EPM-Document Number = 000000_0000000309
An extract of the XML:
<!-- set the number to a generated number -->
- <AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
- <!-- the sequence -->
<Attr id="containerName" />
<Arg>_</Arg>
<Arg>{GEN:wt.enterprise.SequenceGenerator:EPM_seq:6:0}</Arg>
</AttrValue>
- <!-- set the version info to a generated version info -->
- <AttrValue id="MBA|versionInfo" algorithm="com.ptc.core.foundation.vc.server.impl.VersionInfoGenerator">
<Arg>wt.series.HarvardSeries</Arg>
</AttrValue>
(In this case you get an error if no product name is found. But we managed it with the argument to fill the prefix with zeros if no product name is found. The rule with the zeros isn´t written in this extract but the basic problem is the same: In some cases no product name is found --> see the following questions)
Now my questions:
1) Why is the product name found as prefix when I create a new EPM-Document in the intern browser of Creo 2.0 but isn´t found when I create a new EPM-Doc directly in Creo 2.0 with File --> New (the field "name" shows <auto generated name>). The server is connected, the correct workspace is chosen and set as primary and active.
2) I also don´t get the product name as prefix if I rename a offline created CAD-Document.
Proceeding:
create CAD-Doc without a server connection and save it on the harddisk --> close Creo --> open Creo --> connect with Windchill server --> choose workspace and set primary and active --> open the offline created CAD-Doc in Creo --> save it (now it is shown in the workspace) --> place a checkmark in front of the CAD-Doc in the workspace --> File --> Rename --> place a checkmark in front of the CAD-Doc again --> define new name (symbol with the label) --> check the box "auto numbering" --> OK --> OK --> no product name found! Why?
Thank you very much for your help.
Best regards
We use Creo 2.0 M040 and Windchill PDMLink Version: 10.1 M030