Skip to main content
14-Alexandrite
May 9, 2025
Solved

Custom OIR to autonumber by folder

  • May 9, 2025
  • 3 replies
  • 1193 views

Version: Windchill 12.1

 

Use Case: I'm trying to create a rule on OIR to number CAD files based on the folder.

Every folder holds files from a different project and my company wants to number then with a specif prefix and have a new sequence for each folder.


Description:

The rule I've written is the following:

In this code the product context is Treinamento, the folder is PJ123 and the number sequence is PJTESTE that I've created for this folder.
This code is to test in which folder it is been created. Further conditions I will create after the folder condition is working.

<!-- set the number to a generated number -->
	<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
		<Value algorithm="wt.rule.algorithm.CaseBranch">
 		<Value algorithm="wt.rule.algorithm.StringInListTest">
				<Attr id="folder.id"/>
				<Arg>PJ123</Arg>
				<Arg>/PJ123</Arg>
				<Arg>./PJ123</Arg>
				<Arg>Treinamento/PJ123</Arg>
				<Arg>/Treinamento/PJ123</Arg>
				<Arg>./Treinamento/PJ123</Arg>
				<Arg>TreinamentoPJ123</Arg>
				<Arg>*/PJ123</Arg>
				<Arg>/Default/PJ123</Arg>
				<Arg>/Default</Arg>
				<Arg>/Default/PJ123*</Arg>
				<Arg></Arg>
 		</Value>
 			<Arg>0123-</Arg>
			<Arg>not123-</Arg>
		</Value>
		<Arg>{GEN:wt.enterprise.SequenceGenerator:PJTESTE:4:0}</Arg>
	</AttrValue>

 

I've used StringInListTest validation just for track what names for folder I've tried.

 

The rule is not validating the folder. When I'm creating a CAD file in the folder PJ123, in any other folder and in the root the file is named not123-XXXX.

 

Does anyone know why it's not working?

Also, as far as I tested the validation to prefix selects either the first value or second, if I need to add the custom sequence how would I do it? I understand that I can't just add the number sequence with the prefix, as the following example:

<Arg>not123-{GEN:wt.enterprise.SequenceGenerator:PJTESTE:4:0}</Arg>

 

Best answer by VR_4000

So the solution I've found is either make a listener or a custom class. I didn't had the time to try any, but I'm positive they will solve the problem.

3 replies

16-Pearl
May 9, 2025

Try to get the folder path with the wt.rule.algorithm for that purpose https://www.ptc.com/en/support/article/CS20230

VR_400014-AlexandriteAuthor
14-Alexandrite
May 13, 2025

I've tried that, but then it just ignores the numbering rule and name the files as the default (e.g. PRT0001.PRT)

The code modified below:

 

<!-- set the number to a generated number -->
	<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
		<Value algorithm="wt.rule.algorithm.BooleanBranch">
 		<Value algorithm="wt.rule.algorithm.StringEqualsTest">
 			<Value algorithm="wt.rule.algorithm.GetFolderPathAlgorithm">
					<Attr id="folder.id"/>
				</Value>
				<Arg>/Default/PJ123</Arg>
 		</Value>
 			<Arg>0123-</Arg>
			<Arg>not123-</Arg>
		</Value>
		<Arg>{GEN:wt.enterprise.SequenceGenerator:PJTESTE:4:0}</Arg>
	</AttrValue>

 

When removing only GetFolderPathAlgorithm, and leaving only <Attr id="folder.id"/>, the code runs and returns a negative for every file.

 

Also tried to look on the Javadoc for windchill 12.1 and didn't find GetFolderPathAlgorithm class there.

The article that your pointed says it's is for Windchill PDMLink 9.1 M070 to 10.0 M020, maybe it's not part of 12.1 anymore.

 

I've also tried to write the folder path to an attribute the result was nothing, like there was nothing there.

HelesicPetr
22-Sapphire II
22-Sapphire II
May 13, 2025

Hi @VR_4000 

You're right, the class wt.rule.algorithm.GetFolderPathAlgorithm does not exist in Windchill 13.0+ 

 

You can write own. 

 

PetrH

HelesicPetr
22-Sapphire II
22-Sapphire II
May 13, 2025

Hi @VR_4000 

I have experience, that during the upload CAD file information about the folder is missing in the method. 

I tried to solve it with PTC and I've given up because it is internal sw problem that you can not involve. 

 

My case was that a customer wanted to place a CAD to a folder based on some IBA attribute, but the information was not provided in the condition method during upload or checkin operation from the Creo. 

I wrote own method and debug it very deeply and carefully and I found that the condition input does not contain the information about the object and it is problem in any OID conditions. 

 

So I guess it would be similar issue in your case.

 

I solve the users needs by creating listener that moves the new object to correct place folder.

You could do it with renumbering. 

 

PetrH

VR_400014-AlexandriteAuthor
14-Alexandrite
May 13, 2025

Just to making sure I understood you right, the folder.id value is not accessible from a OIR, right? And that's why I can't do what I trying to.

And how did you made that listener?

HelesicPetr
22-Sapphire II
22-Sapphire II
May 13, 2025

Hi @VR_4000 

Actually I described a little bit different issue, but yours seams it is almost same.

Yes I guess that during the check algorithm the method does not contains the correct input from the folder.id

In one specific operation - check-in. 

If I upload the CAD the OIR algorithm worked without any issue, but if I check-in the CAD Document then the OIR algorithm is called again, and that moment the input does not contain the correct information about the attribute.

I guess that the main point can be that the path is not really stored in a database that moment and it needs more deep investigation.  

 

Listener is coding customization that can be found in a Customization guide. 

CS213788 - How to create a Listener in Windchill PLM

Windchill 13.0.2.0 Customization Guide

PetrH 

VR_400014-AlexandriteAuthorAnswer
14-Alexandrite
May 20, 2025

So the solution I've found is either make a listener or a custom class. I didn't had the time to try any, but I'm positive they will solve the problem.