cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to set CAD Doc Name = CAD Doc Number less extension rather than = CAD filename less extension ?

NickD
8-Gravel

How to set CAD Doc Name = CAD Doc Number less extension rather than = CAD filename less extension ?

By tweaking the OOTB OIRs (to remove the GetServerAssignedConstraint from the "number" AttrConstraints) and setting some Preferences, we have almost got what we need, but not quite. As shown on the screen grab image below (if it is legible...) we have got the CAD filename driving the CAD Doc Number (which has to be unique, and it goes into CAPITALS regardless of the case of the filename), and similalry CAD Doc Name is based on CAD filename but dropping the extension - so it is quite literally becoming the "common name" for associated parts, drawings and WTParts (and these are being autonumbered). The CAD filenames come from an external system, that generates document numbers in CAPITALS. All of this is what we want except the case being used for the CAD Doc Names.

The discrepancy we are left with is due to the different behaviour or Pro/E and SolidWorks, where Pro/E always puts the filename into lowercase, but SolidWorks preserves the case of the filename as it was entered in the UI. As a result, the CAD Doc Names are created in the case set by each of the CAD tools, but the CAD Doc Numbers are always put in CAPITALS by Windchill. What we would like is to get all the CAD Doc Names also put into CAPITALS as well (without the filename extensions), so they can all be searched and browsed more easily.

We have discovered in some early testing of v10.0 for ECAD (where empty ECAD Docs are created first, then ZIP files are attached - so they have to be named and numbered without any reference to the filenames) that we can edit the ECAD OIRs to drive the CAD Doc Name from the CAD Doc Number, and also prevent the user from entering the CAD Doc Name (so they only have to enter one thing). Since the CAD Doc Number is put into CAPITALS by Windchill, we get them both in CAPITALS regardless of what case the user types in for the Number (and we regard this as perfect).

So, we have just tried adding the following to our CAD OIRs (and un-set the Preferences mentioned above), but Name is not being copied from Number.

<!-- set the name to be the same as the number but without the filename extension portion -->

<AttrValue id="name" algorithm="wt.rule.algorithm.Substring">

<Attr id="number"/>

<Arg>0</Arg>

<Value algorithm="wt.rule.algorithm.IndexOf">

<Attr id="number"/>

<Arg>.</Arg>

</Value>

</AttrValue>

<AttrConstraint id="name" algorithm="com.ptc.core.rule.server.impl.GatherAttributeConstraints">

<Value algorithm="com.ptc.core.rule.server.impl.GetServerAssignedConstraint"/>

<Value algorithm="com.ptc.core.rule.server.impl.GetImmutableConstraint"/>

</AttrConstraint>

Can anyone see or suggest what we need to do to stop the CAD filename being used to drive the CAD Doc Name, and let the OIR create the CAD Doc Name instead from the CAD Doc Number (in CAPITALS, and without the filename extension) ?

Any help gratefully received.

Names_Numbers_Filenames_OK_new_files_2.gif

1 ACCEPTED SOLUTION

Accepted Solutions
ngiacom
14-Alexandrite
(To:NickD)

ModelName is the string that you insert in Proe. FileName becomes modelname.prt. Number becomes MODELNAME.PRT and Name becomes MODELNAME (with custom EPMDocumentNamingDelegate, the default behaviour should modelname.prt or modelname by preference).

The class is simple, I don't know if it works in 9.1.

package ext.yourcompany...

import com.ptc.windchill.uwgm.proesrv.c11n.DocIdentifier;

import com.ptc.windchill.uwgm.proesrv.c11n.EPMDocumentNamingDelegate;

public class EPMDefaultDocumentNamingDelegate implements EPMDocumentNamingDelegate {

@Override

public void validateDocumentIdentifier(DocIdentifier docIdentifier) {

String name = docIdentifier.getDocNumber();

if (name.contains(".")) {

name = name.substring(0, name.lastIndexOf("."));

}

docIdentifier.setDocName(name.toUpperCase());

}

}

The rename is an other Universe. This approach is valid only the first time that you upload a cad document.

As said before I found UwgmEvent.PRE_RENAME ... (it should be tested).

Are you welcome.

Nicola

View solution in original post

12 REPLIES 12
ngiacom
14-Alexandrite
(To:NickD)

Hello, do you have the preference Operation > Upload Operation > Upload > Upload Drop Name File Extension?

There is this preference in my Windchill 10.1 and it works.

I tried other solutions without success:

OIR --> doesn't work

custom EPMDefaultNamingDelegate --> doesn't work

The preference setting from Nicola suggests is what we use; back to 9.1. BUT, we still have an issue with users being able to Rename and do whatever they want. The system does not enforce this on renames. We have complained to PTC, but no resolution after a year.

We have used all four of the following Preferences to get the behaviour shown in the screen grab image in my original posting, and they all work as expected in v9.1

WGM / Client / Sync’ Number & Filename = Yes, & Locked (This option is applied when creating new files from an authoring application. Number may be with or without file extension depending on the preferences "Upload Drop Number File Extension")

WGM / Server / New CAD Doc’ / Sync’ CAD Model Name with CAD Doc Number = Yes, & Locked (This synchronization is not applicable when auto numbering is in effect)

WGM / Server / Auto Associate / Auto Associate Truncate Name File Extension (changing it to Yes, and Locked)

WGM / Client / Upload / Upload Drop Name File Extension (changing it to Yes)

But what we are trying to do now is keep the same CAD Doc Numbering behaviour, ie. it goes into CAPITALS when copied from the CADName (filename), and then get that Number (in CAPS) truncated and copied into the Name using the following OIR entries - and we are currently trying this with all of the Prefs listed above set back to thier OOTB defaults :

<!-- set the number to a CAD File name -->

<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">

<Attr id="CADName"/>

</AttrValue>

<!-- set the name to be the same as the number but without the filename extension -->

<AttrValue id="name" algorithm="wt.rule.algorithm.Substring">

<Attr id="number"/>

<Arg>0</Arg>

<Value algorithm="wt.rule.algorithm.IndexOf">

<Attr id="number"/>

<Arg>.</Arg>

</Value>

</AttrValue>

The results of this are: Name (in lowercase) = Number (in UPPERCASE) = CADName (in lowercase).

ngiacom
14-Alexandrite
(To:NickD)

I think that the problem is about the Policy-Managed Naming and Numbering. In your case is name-driven. Then the name is the creo file name. CADName is the name + extension. Number is CADName uppercase.

Maybe if you had the number-driven or parameter-driven policy your OIR (or EPMDefaultNamingDelegate) should work.

Eventually you (and Rick) could implement a custom service on event EPMWorkspaceManagerEvent.POST_WORKSPACE_CHECKIN that changes the name.

Have you opened a ptc case? What they say about this issue?

We want what Pro/E wants. CADName is the unique key. But WC the unique key is Number. So we try to get Number driven from CADName (and it is on uploads) but users can change Number without changing the CADName, thus causing a problem. PTC of course says this is fine and that we need to customize or submit an enhancement request that will never be implemented (which we have done).

Customization is rarely simple. Your suggested event, I don’t think is triggered on a rename. There is no Check out for this task….correct?

ngiacom
14-Alexandrite
(To:ptc-1917366)

Can you remove "rename" access to your bad users?

Otherwise I found UwgmEvent.PRE_RENAME ... it should be tested.

NickD
8-Gravel
(To:ngiacom)

I have started another discussion thread about Rename ( http://communities.ptc.com/message/189314#189314 ), so can we please keep this thread on the original subject of configuring CAD Doc naming and numbering through OIRs, Prefs and any other system settings ?

We are happy with CAD Doc Number being set from CAD filename.ext and being put into capitals.

but we want to set CAD Doc Name from either :

(a) CAD Doc Number (in CAPITALS) after dropping the .EXT, or

(b) CAD filename.ext (in lower or mixed case) after dropping the .ext and changing it to CAPITALS

and then we want WTParts to get the same Name as CAD Doc Name, and be auto-Numbered.

I just spotted this thread : http://communities.ptc.com/message/149027#149027 in which PTC say name and number are set in the Workspace and Number is then set upon upload (based on OIRs), so because of this sequence it may be that we have to settle for the setup shown on my original posting, and concentrate instead on configuring and/or customising the Rename behaviour to get the result we want consistently...?

Further re-reading of the "using Pro/E with Windchill" Guide has confirmed that the name-driven policy will do almost everything we want (and indeed that is what we had set up originally, as it does actually allow for WTParts to be auto-Numbered via the OIRs). However we will need to customise the Naming Service to get the CAD Doc Name (and thus the WTPart Name) exactly as described in (b) above. Doing this looks similar to customising the download delegate (which we have just completed), so now I am looking for examples of customised Naming Service files that use setDocName with getModelName (the CAD filename) but with a bit of extra java code to drop the filename extension and switch the resulting string into CAPITALS. PTC's document TPI 132080 looks like it offers a good starting point (but once again they omit showing an example of the command to compile the class - but this can be found elsewhere, such as in CS20729).

Does anyone have any examples of customised Naming Service files that they are willing to share on this forum ?

ngiacom
14-Alexandrite
(To:NickD)

Ok Nick. Perhaps I have the solution via EPMDocumentNamingDelegate.

I did all steps in Using Creo Parametric® with Windchill Guide (Naming Services) and I writed my custom class that implements the validateDocumentIdentifier method. I putted it in services.properties.

It works for me...example:

Model name: nick

File name: nick.prt

Number: NICK.PRT

Name:NICK

Is this what you want?

Video Link : 3330

NickD
8-Gravel
(To:ngiacom)

That looks exactly what I want !

The only questions I have now are :

(1) what is Model name (I recognise the other three, but a forth one is new to me) ?

(2) does this also control the behaviour in Rename

(3) can you send me a copy of the java file ?

Many thanks for confirming the approach, and for sharing your knowledge

best regards

Nick Drought

ngiacom
14-Alexandrite
(To:NickD)

ModelName is the string that you insert in Proe. FileName becomes modelname.prt. Number becomes MODELNAME.PRT and Name becomes MODELNAME (with custom EPMDocumentNamingDelegate, the default behaviour should modelname.prt or modelname by preference).

The class is simple, I don't know if it works in 9.1.

package ext.yourcompany...

import com.ptc.windchill.uwgm.proesrv.c11n.DocIdentifier;

import com.ptc.windchill.uwgm.proesrv.c11n.EPMDocumentNamingDelegate;

public class EPMDefaultDocumentNamingDelegate implements EPMDocumentNamingDelegate {

@Override

public void validateDocumentIdentifier(DocIdentifier docIdentifier) {

String name = docIdentifier.getDocNumber();

if (name.contains(".")) {

name = name.substring(0, name.lastIndexOf("."));

}

docIdentifier.setDocName(name.toUpperCase());

}

}

The rename is an other Universe. This approach is valid only the first time that you upload a cad document.

As said before I found UwgmEvent.PRE_RENAME ... (it should be tested).

Are you welcome.

Nicola

NickD
8-Gravel
(To:ngiacom)

We have now setup a customised Naming Service (EPMDocumentNamingDelegate...) with the java code you suggested, and tested it with PDMLink v9.1 M062 using both WF3 and SolidWorks v2010, and confirmed we get the desired results as shown on this screen gab image :

FileName-ext_NAME_NUMBER-EXT.gif

Thank you for your help. Next thing for us is to find out why the folder sorting by OIRs is not working (as per my other posting http://communities.ptc.com/message/189312#189312 ), and start to investigate the behaviour or Rename...

NickD
8-Gravel
(To:NickD)

Another refinement we are now looking for is to adapt the data migration process from Intralink v3.4 so that the migrated files (and resulting CAD Dcoumnets) match the naming convention described above. I believe this will need a bulk/global CAD Document renaming command to remove the filename extensions from all CAD Document Names that have been created by the v9.1 Intralink Data migrator and swap them to uppercase. Any suggestions for how this might be done in Windchill PDMLink ?

Another approach might be to adapt a copy of the "set common name" SQL script provided for TAN 132021 / SPR 1155075, to not just copy the filename.ext into the PTC_COMMON_NAME attribute, but to also drop the filename extension and change the case to uppercase. Does anyone know how to do this in a sql script ?

Top Tags