Skip to main content
14-Alexandrite
January 17, 2020
Question

Windchill publish rule without prefix from DRW

  • January 17, 2020
  • 2 replies
  • 2944 views

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. 

2 replies

MattPat14-AlexandriteAuthor
14-Alexandrite
January 17, 2020

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

17-Peridot
January 17, 2020

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

MattPat14-AlexandriteAuthor
14-Alexandrite
January 17, 2020

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. 

23-Emerald IV
January 17, 2020

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;
	}