Skip to main content
1-Visitor
Oct 17, 2017 4:19 PM UTC
Solved

Windchill Listener Rename only on first checkin

Hi All,

 

I have written a windchill listener that waits for EPMWorkspaceManagerEvent.PRE_WORKSPACE_CHECKIN events, and then changes the names of epm documents, and parts in certain ways depending on some IBA.

 

It works fine, a part from the fact that I am unable to distinguish between the first checkin, when the autonumber is substituted with the proper computed-by-the-listener name, and all the following checkins.

 

For example, I checkin the part 295.prt, and it gets renamed to NEWNAME-142-DONE.prt; then, I modify it, and check it in again, but instead of becoming A.2, it becomes NEWNAME-143-DONE.prt, version A.1. This does not happen to the WTPart, which is renamed as well initially, but then keeps the same name and only increases the iteration.

 

Is there any attribute of the EPMDocument that I can check? Any API that could help me?

 

(I may check the format of the name to verify if it has been already renamed, but I would prefer to use something else, beacuse it may be the case that parts with a different format exist and they should keep the different name).

 

Thank you in advance.

 

Regards

 

Davide

davidegpAnswer
1-Visitor
Oct 23, 2017 4:16 PM UTC

I have found a solution that I publish here, just in case someone else may need it,

 

for prt and asm,

 

 public boolean understandModifications() throws WTException {
 if (WorkInProgressHelper.service.isPreCheckedInObject(this.associated)) {
 return true;
 } else {
 return false;
 }
 }

isPreCheckedInObject returns true only the first time that a prt or assembly is checked in in Windchill.

 

However, this does not work for drawings. So, I used a workaround,

public boolean understandModifications() {
 // the drawingReference is the document master of the drawing
 EPMDocumentMaster activePart = this.drawingReference;
 // the getRelatedSinglePart method failed!
 if (activePart == null) {
 System.out.println("getDrawingReference failed.");
 return false;
 }
 // if the drawing has already been renamed, skip it!
 String subNumberPart = activePart.getNumber().substring(0, activePart.getNumber().indexOf("."));
 String subNumberDrw = doc.getNumber().substring(0, doc.getNumber().indexOf("."));
 if (subNumberDrw.equalsIgnoreCase(subNumberPart)) {
 return false;
 } else {
 return true;
 }
 }

Here, I confront the name of the drawing with the one of the document master associated with it. If they are the same, it means that I have already renamed them in a previous checkin, so this is not the first one. Otherwise, this is the first one.

3 replies

davidegp1-VisitorAuthorAnswer
1-Visitor
Oct 23, 2017 4:16 PM UTC

I have found a solution that I publish here, just in case someone else may need it,

 

for prt and asm,

 

 public boolean understandModifications() throws WTException {
 if (WorkInProgressHelper.service.isPreCheckedInObject(this.associated)) {
 return true;
 } else {
 return false;
 }
 }

isPreCheckedInObject returns true only the first time that a prt or assembly is checked in in Windchill.

 

However, this does not work for drawings. So, I used a workaround,

public boolean understandModifications() {
 // the drawingReference is the document master of the drawing
 EPMDocumentMaster activePart = this.drawingReference;
 // the getRelatedSinglePart method failed!
 if (activePart == null) {
 System.out.println("getDrawingReference failed.");
 return false;
 }
 // if the drawing has already been renamed, skip it!
 String subNumberPart = activePart.getNumber().substring(0, activePart.getNumber().indexOf("."));
 String subNumberDrw = doc.getNumber().substring(0, doc.getNumber().indexOf("."));
 if (subNumberDrw.equalsIgnoreCase(subNumberPart)) {
 return false;
 } else {
 return true;
 }
 }

Here, I confront the name of the drawing with the one of the document master associated with it. If they are the same, it means that I have already renamed them in a previous checkin, so this is not the first one. Otherwise, this is the first one.

Translate
1-Visitor
Oct 25, 2017 5:35 PM UTC

Thanks for posting the solution. By why not just check to see if the version is A.1 or not?

Translate
davidegp1-VisitorAuthor
1-Visitor
Oct 30, 2017 11:34 AM UTC

Unfortunately, as I wrote above, the part or assembly was renamed each time, and it got A1 as version! I could have checked the WTPart that was never renamed twice, and got the A2, but it would have meant do something at every checkin.

 

With the code above, I am able to just check if it is the first checkin; if not, I just skip all the operations. 

Translate