Skip to main content
15-Moonstone
October 5, 2020
Solved

How to prohibit publishing of CAD documents based on name

  • October 5, 2020
  • 1 reply
  • 3290 views

I want to exclude certain EPM documents from publishing based on their naming convention in a way that can also capture whether the EPM document is a .asm or .drw, does anyone know of any methods we could use to filter by name so items do not go the the publishing queue?

Best answer by khimani_mohiki

Heres the Publish rule I used to control what get submitted for publishing based on EPM document name, in thoery this allows us to reduce our publishing by up to 90% by only publishing items that are actually useful to view. this also allows us to create schedule publish jobs to clean up items with no representations due to job failurs etc.

 

The trickey bit was the regex syntax to find the EPMdoc names

 

I added some <additional files> publishing to the rule as an added benefit.

 

This table shows what we want to publish and on what trigger:

 

Published by rule (Y/N) 7-fig part & assembly (#######.prt, #######.asm) 7-fig drawing (#######.drw) CAD number (CAD*.prt, CAD*.asm) scheme assembly (sc*.asm) Scheme drawing (sc*.drw) TR & PR DRAWINGS (tr*.drw, pr*.drw) TR & PR parts (tr*.prt, tr*.asm, pr*.prt, pr*.asm)
checkin Y Y Y N Y Y N
schedule (LATEST NO REP) Y Y N N N Y N
create rep Y Y Y Y Y Y Y

 

<rules xmlns="http://www.ptc.com" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ptc.com PublishRulesSchema.xsd">

<!-- version 4 -->

<authoring-application name="PROE">

<!-- conditions to identify items based on part number and extension to determine if they should be published -->

<condition name="7_FIG_PART">

<or>

<attribute name="epmdoc_CADName" regex="\b[0-9][0-9][0-9][0-9][0-9][0-9][0-9].*\.*asm" />
<attribute name="epmdoc_CADName" regex="\b[0-9][0-9][0-9][0-9][0-9][0-9][0-9].*\.*prt" />

</or>

</condition>

<condition name="7_FIG_DRAWING">

<attribute name="epmdoc_CADName" regex="\b[0-9].*\.*drw" />

</condition>

<condition name="SCHEME_DRAWING">

<or>

<attribute name="epmdoc_CADName" regex="\bSC.*\.*drw" />
<attribute name="epmdoc_CADName" regex="\bsc.*\.*drw" />

</or>

</condition>

<condition name="TR_OR_PR_DRAWING">

<or>

<attribute name="epmdoc_CADName" regex="\bPR.*\.*drw" />
<attribute name="epmdoc_CADName" regex="\bTR.*\.*drw" />
<attribute name="epmdoc_CADName" regex="\bpr.*\.*drw" />
<attribute name="epmdoc_CADName" regex="\btr.*\.*drw" />

</or>

</condition>

<condition name="CAD_NUMBER">

<or>

<attribute name="epmdoc_CADName" regex="\bCAD.*" />
<attribute name="epmdoc_CADName" regex="\bcad.*" />

</or>

</condition>

<condition name="Scheme_ASSY">

<or>

<attribute name="epmdoc_CADName" regex="\bSC.*\.*asm" />
<attribute name="epmdoc_CADName" regex="\bsc.*\.*asm" />

</or>

</condition>

<condition name="TR_OR_PR_PARTS_AND_ASSEMBLIES" >

<or>

<attribute name="epmdoc_CADName" regex="\bPR.*\.*asm" />
<attribute name="epmdoc_CADName" regex="\bTR.*\.*asm" />
<attribute name="epmdoc_CADName" regex="\bPR.*\.*prt" />
<attribute name="epmdoc_CADName" regex="\bTR.*\.*prt" />
<attribute name="epmdoc_CADName" regex="\bpr.*\.*asm" />
<attribute name="epmdoc_CADName" regex="\btr.*\.*asm" />
<attribute name="epmdoc_CADName" regex="\bpr.*\.*prt" />
<attribute name="epmdoc_CADName" regex="\btr.*\.*prt" />

</or>

</condition>


<!-- Publish additional files -->

<additional-files name="2D">
<file output-prefix="pdf" default="false" type="pdf" visible="true" display-label="PDF_file"/>
<file output-prefix="dxf" default="false" type="dxf" visible="true" display-label="dxf_file"/>
</additional-files>

<additional-files name="3D">
<file type="step" display-label="STEP_file" default="false" visible="true" output-prefix="Step_file"/>
<file display-label="iges_3D" type="iges" default="false" visible="true" output-prefix="Iges_file"/>
</additional-files>

<!-- START IFs -->

<if condition="7_FIG_PART">

<publish on="checkin" />
<publish on="create-representation"/>
<publish on="create-representation" additional-files="3D"/>
<publish on="schedule" />

</if>

<if condition="7_FIG_DRAWING">

<publish on="checkin" />
<publish on="create-representation"/>
<publish on="create-representation" additional-files="2D"/>
<publish on="schedule" />

</if>

<if condition="SCHEME_DRAWING">

<publish on="checkin" />
<publish on="create-representation"/>
<publish on="create-representation" additional-files="2D"/>

</if>

<if condition="TR_OR_PR_DRAWING">

<publish on="checkin" />
<publish on="create-representation"/>
<publish on="create-representation" additional-files="2D"/>
<publish on="schedule" />

</if>

<if condition="CAD_NUMBER">

<publish on="checkin" />
<publish on="create-representation"/>
<publish on="create-representation" additional-files="3D"/>
<publish on="create-representation" additional-files="2D"/>

</if>

<if condition="Scheme_ASSY">

<publish on="create-representation"/>
<publish on="create-representation" additional-files="3D"/>

</if>

<if condition="TR_OR_PR_PARTS_AND_ASSEMBLIES">

<publish on="create-representation"/>
<publish on="create-representation" additional-files="3D"/>

</if>

<publish on="create-representation" additional-files="3D"/>
<publish on="create-representation" additional-files="2D"/>

</authoring-application>

</rules>

  

1 reply

15-Moonstone
October 14, 2020

So I think I need to create publish rules to evaluate the EPMdoc name, but I have no idea where to start, does anyone have any examples? 

23-Emerald IV
October 14, 2020

I'm certainly no developer, but here's something I put together several years ago to prevent certain things from getting published.

package ext;

import wt.epm.EPMDocument;
import wt.epm.EPMDocumentType;
import wt.epm.EPMAuthoringAppType;
import wt.fc.Persistable;
import wt.wvs.WVSLogger;

public class TMPublishHelper {

	private static final WVSLogger logger = WVSLogger.getLogger(TMPublishHelper.class, WVSLogger.PUBLISH_GROUP);
	// Log Levels
	// logger.fatal("Fatal message");
	// logger.error("Error message");
	// logger.warn("Warn message");
	// logger.info("Info message");
	// logger.debug("Debug message");
	// logger.trace("Trace message");
	
	public static Boolean shouldPublishEPMDoc(EPMDocument d) {
		boolean shouldPublishFlag = true;

		String cadName = d.getCADName();
		logger.debug(cadName + " is ready to publish.");
		if (cadName.endsWith(".mfg") || cadName.endsWith("_harn.prt") || cadName.endsWith ("_mfg.asm") || cadName.endsWith ( "_flat.asm") || cadName.endsWith (".idr")) {
			logger.debug(cadName + ": will not be published due to file type.");
			shouldPublishFlag = false;
		}
		// String containerName = d.getContainerName();
		// if (containerName.equals("User Files")) {
			// logger.debug(cadName + " : filtered due to context");
			// shouldPublishFlag = false;
		// }
		if (shouldPublishFlag) {
			logger.debug(" **************** Succedded...!!!");
		}
		return Boolean.valueOf(shouldPublishFlag);
	}
}

 

15-Moonstone
October 14, 2020

Hello Tom, Im even less of a developer, I can see roughly whats goin on in your code, but where does it go and how are you envoking it?

 

Any help much appreciated, this is a very murky topic.