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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Windchill publish rule without prefix from DRW

MattPat
12-Amethyst

Windchill publish rule without prefix from DRW

Hi,

My client wants that generated PDF and DXF from DRW should have the same name as the primary file. Now it looks like this:

 

MattPat_0-1579257805278.png

 

Files should be named testpart.dxf and testpart.pdf without prefix "dxf_" and suffix "_drw".

My publish rule look like this:

Spoiler
<rules xmlns="http://www.ptc.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ptc.com/PublishRulesSchema.xsd">  
	<authoring-application name="PROE">  
		<additional-files name="DrawingPDF">  
			<file display-label="PDF" type="pdf" default="true" output-prefix="pdf"/> 
			<file display-label="DXF" type="dxf" default="true" output-prefix="dxf"/>
		</additional-files>  
		<param-set name="Share with WTDocumentReleased Drawing">  
			<post-publish name="delegate">com.ptc.wvs.server.publish.AdditionalFilesPostPublishDelegate</post-publish>  
			<post-publish name="published-content-link">pdf</post-publish>  
			<post-publish name="name">{EPM_NAME}</post-publish>  
			<!-- <post-publish name="lifecycle-state">RELEASED</post-publish>  -->
			<post-publish name="lifecycle-template">Basic</post-publish>  
			<post-publish name="type">wt.doc.WTDocument</post-publish>  
			<post-publish name="folder">/default/PDFs</post-publish>  
			<post-publish name="additional-file-primary">.*\.pdf</post-publish>
			<post-publish name="additional-file-secondary">.*\.dxf</post-publish>
		</param-set>  
		<condition name="IS_Drawing">  
			<attribute name="epmdoc_name" regex=".*\.drw" />  
			<!-- <attribute name="epmdoc_lifeCycleState" value="Released"/>  -->
		</condition>  
		<if condition="IS_Drawing">  
			<publish evaluate-rules-on-republish="true"  additional-files="DrawingPDF" param-set="Share with WTDocumentReleased Drawing" on="create-representation"/>  
			<publish evaluate-rules-on-republish="true"  additional-files="DrawingPDF" param-set="Share with WTDocumentReleased Drawing" on="schedule"/>  
			<publish evaluate-rules-on-republish="true"  additional-files="DrawingPDF" param-set="Share with WTDocumentReleased Drawing" on="checkin"/>  
			<publish evaluate-rules-on-republish="true"  additional-files="DrawingPDF" param-set="Share with WTDocumentReleased Drawing" on="unknown-source"/>
			<!-- <publish evaluate-rules-on-republish="true"  additional-files="DrawingPDF" param-set="Share with WTDocumentReleased Drawing" on="manual-post"/> -->
		</if>  
		<publish evaluate-rules-on-republish="true" on="checkin"/>  
		<publish evaluate-rules-on-republish="true" on="create-representation"/>  
		<publish evaluate-rules-on-republish="true" on="schedule"/>  
		<publish evaluate-rules-on-republish="true" on="unknown-source"/>  
		<publish evaluate-rules-on-republish="true" on="manual-post"/>
	</authoring-application>  
</rules>  

Thank you for help. 

7 REPLIES 7
MattPat
12-Amethyst
(To:MattPat)

I see that value output-prefix is mandatory. Is it any way to solve it ? 

The only possibility I'm aware of ist to create an AfterEDRLoader like described in the case CS216668.

Thank you for the quick response. Why PTC can't allow it to make in publish rule. It doesn't make sense. I have to create file and another method will only change the name of this file.  

Ok all is clear but this method output file names will be: source CAD file name + Windchill version number. i.e. Format: <CADName>_<IterationInfo>.extension (e.g. MYCADNAME_A.1.stp)

It's not what I'm looking for because I need only a name from drw file. 

TomU
23-Emerald IV
(To:MattPat)

You can modify the Java file provided in that KB article to meet your needs.  For example, I have ours configured to use the object's file name (without extension) + space + revision:

 

TomU_0-1579269278991.png

 

Here is the relevant section of code:

	public static String[] renameAdditionalfiles(Representable repable,
                                     Persistable object,
                                     Representation rep,
                                     NavigationCriteria docCriteria,
                                     NavigationCriteria partCriteria,
                                     int structureType)
	{
		String[] ret = {"AfterEDRloader: Renaming additional files"};

		if (object instanceof EPMDocument) {

			Transaction trx = new Transaction();
			try {
				trx.start();

				Representation ch = (Representation)ContentHelper.service.getContents(rep);
				EPMDocument cadDoc = (EPMDocument)object;
				ApplicationData appData = null;
				Vector<?> appDatas = null;
				String fileName = null;
				String sName = null;
				String fileExt = null;
				String postfix = null;
	            InputStream is = null;
				String iterationInfo = cadDoc.getVersionDisplayIdentifier().toString();			
				appDatas = ContentHelper.getContentList(ch);
				int num_of_files = appDatas.size();

				for (int i = 0; i < appDatas.size(); i++) {
					appData = (ApplicationData)appDatas.get(i);
					String sFileName = cadDoc.getCADName();

					if (appData.getRole() != null && appData.getRole().equals(ContentRoleType.ADDITIONAL_FILES)) {
						fileName = appData.getFileName();
						postfix = fileName.substring(fileName.lastIndexOf("_")+1);
						fileExt = fileName.substring(fileName.lastIndexOf(".")+1);

						if (fileExt.equals("zip"))
						{
							sFileName = sFileName.substring(0, sFileName.lastIndexOf(".")).toUpperCase() + " " + iterationInfo +  " " + postfix;
						} else {
							sFileName = sFileName.substring(0, sFileName.lastIndexOf(".")).toUpperCase() + " " + iterationInfo +  "." + fileExt;						
						}
					
						appData.setFileName(sFileName);

						is = ContentServerHelper.service.findContentStream(appData);
						ContentServerHelper.service.updateContent(ch, appData, is);
					}
				}
            trx.commit();
            trx = null;

			} catch (WTPropertyVetoException e) {
				e.printStackTrace();
			} catch (PropertyVetoException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} catch (WTException e) {
				e.printStackTrace();
			} finally {
				if (trx != null) {
					trx.rollback();
					trx = null;
				}
	        }

		}

	  return ret;
	}

 

MattPat
12-Amethyst
(To:TomU)

Hi Tom,

Thank you for your help. Summarizing I have to install Afterloader hook method and after that modify the Java code of Afterloader? Sorry for my confusion but it's first time to me for making Windchill customization. 

TomU
23-Emerald IV
(To:MattPat)

Hopefully you have a test system...

Follow the steps in the KB article exactly.  (In step 5, use option 1 only.)  Once you have that working you can tweak the contents of the Java file, recompile (Windchill shell command), and then restart Windchill to see the changes.  Repeat this process until you're happy with the results.

Top Tags