Skip to main content
15-Moonstone
October 18, 2022
Solved

Prohibit CAD Document publish in state Under Review

  • October 18, 2022
  • 3 replies
  • 2547 views

Hi,

Is there a way to prohibit publish of CAD Documents entirely based on a specific life cycle state, in this case "Under Review"? It does not add any value for the publish to run because of Promotion process.

 

I've tried to work around with this in the publishrules.xml / Visualization Configuration Administration, but this is not the solution because it's not that straight forward with the other state values:

<not>
<attribute name="epmdoc_lifeCycleState" value="Under Review"/>
</not>

 

Just simply tell somewhere "if state is Under Review do not trigger publish", but where?

Best answer by HelesicPetr

Hi @HJ1 

Yes the publish actions are outside of if condition

because if the condition is not met it will publish all other situations. 

 

You can also combinate it with other conditions. 

 

The best would be to share the PublishRule xml to see what could be wrong. 

 

 Be careful to combinate more conditions together. The sequence of conditions is very important .

If first condition is met the second is not used anymore for one object.

 

It happened to me many times.  

 

My full example> (if conditions are not met it will publish standard_files configuration)

<?xml version="1.0"?>
<rules evaluate-rules-on-republish="true"
	xsi:schemaLocation="http://www.ptc.com PublishRulesSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ptc.com">
	<authoring-application name="PROE"> 
		<additional-files name="standard_files">
			<!-- only default='true' files will be generated at this time -->
			<file output-prefix="step" default="false" type="step" display-label="STEP"/>
			<file output-prefix="iges" default="false" type="iges" display-label="IGES"/>
			<file output-prefix="dxf" default="false" type="dxf" display-label="DXF"/>
			<file output-prefix="cgm" default="false" type="cgm" display-label="CGM"/>
			<file output-prefix="pdf" default="false" type="pdf" display-label="pdf"/> 
		</additional-files>		

		<additional-files name="released_drawing">
			<!-- only default='true' files will be generated at this time -->
			<file output-prefix="dxf" default="true" type="dxf" display-label="DXF"/>
			<file output-prefix="pdf" default="true" type="pdf" display-label="pdf"/> 
		</additional-files>

		<condition name="do_not_publish">
			<and>
				<attribute name="epmdoc_lifeCycleState" value="Under Review"/>
			</and>
	</condition>
			
	<condition name="is_released_drawing">
			<and>
				<attribute name="epmdoc_CADName" regex=".*\.drw" />
				<or>
					<attribute name="epmdoc_lifeCycleState" value="Released"/>
					<attribute name="epmdoc_lifeCycleState" value="Uvolněno"/>
					<attribute name="epmdoc_lifeCycleState" value="Schvaleno"/>
				</or>
			</and>
	</condition>

		<if condition="do_not_publish">
		</if>
		
		<if condition="is_released_drawing">
			<publish on="checkin" display-label="Released Drawing" additional-files="released_drawing"/>
		 <publish on="create-representation" display-label="Released Drawing" additional-files="released_drawing" />
		 <publish on="schedule" display-label="Released Drawing" additional-files="released_drawing"/>
		 <publish on="unknown-source" display-label="Released Drawing" additional-files="released_drawing"/>
		</if>
		
		<publish additional-files="standard_files" on="checkin"/>
		<publish additional-files="standard_files" on="create-representation"/>
		<publish additional-files="standard_files" on="schedule" />
		<publish additional-files="standard_files" on="unknown-source" />
	</authoring-application> 
</rules>

 

PetrH

3 replies

23-Emerald IV
October 18, 2022

Use one of the filter methods and a Java file to analyze state and determine whether to proceed or not.

 

publish.positioningassembly.filtermethod=ext.TMPublishHelper/shouldPublishEPMDoc

 

Here is an example that blocks publishing for certain file types:

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) {
		// This method will never get called by Windchill if the one below it (getPosAsminfo) is being used. The stuff below is just an example...
		
		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;
		}
		if (shouldPublishFlag) {
			logger.debug(" **************** Succedded...!!!");
		}
		return Boolean.valueOf(shouldPublishFlag);
	}
23-Emerald IV
October 18, 2022

This would be the better one to use.  The previously mentioned filter is specific to assemblies.

 

publish.service.filterpublishmethod=

 

We use this filter and some corresponding Java code to block 'under review' re-publishing for everything except the drawing.  (We want that to republish so we can watermark 'under review' on it.)

 

if (epm.getLifeCycleState().equals(State.UNDERREVIEW)

... do stuff ...

 

HelesicPetr
22-Sapphire II
22-Sapphire II
October 19, 2022

Hello @HJ1 

Publish rules can cover your needs. You need to just define condition where publish action is not used.

 

example

	<condition name="do_not_publish">
			<and>
				<attribute name="epmdoc_lifeCycleState" value="Under Review"/>
			</and>
	</condition>
	
		<if condition="do_not_publish">
		</if>
		
		<publish additional-files="standard_files" on="checkin"/>
		<publish additional-files="standard_files" on="create-representation"/>
		<publish additional-files="standard_files" on="schedule" />
		<publish additional-files="standard_files" on="unknown-source" />

 

PetrH

 

HJ115-MoonstoneAuthor
15-Moonstone
October 19, 2022

Hi @HelesicPetr !

 

Sorry, I'm useless with these... which part is it that leaves out publish entirely, in your example you've got the "<publish..." lines outside the if-clause, that it?

<if condition="do_not_publish">
		</if

 

Because, I tested with entering just that empty if clause (and the condition, of course) and first it seemed to work, but after further editing the rule it didn't.. not sure now if I got your idea right  🙄     It is something like this I'm looking for and tested, but never got the syntax right.

 

 

HelesicPetr
22-Sapphire II
22-Sapphire II
October 19, 2022

Hi @HJ1 

Yes the publish actions are outside of if condition

because if the condition is not met it will publish all other situations. 

 

You can also combinate it with other conditions. 

 

The best would be to share the PublishRule xml to see what could be wrong. 

 

 Be careful to combinate more conditions together. The sequence of conditions is very important .

If first condition is met the second is not used anymore for one object.

 

It happened to me many times.  

 

My full example> (if conditions are not met it will publish standard_files configuration)

<?xml version="1.0"?>
<rules evaluate-rules-on-republish="true"
	xsi:schemaLocation="http://www.ptc.com PublishRulesSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ptc.com">
	<authoring-application name="PROE"> 
		<additional-files name="standard_files">
			<!-- only default='true' files will be generated at this time -->
			<file output-prefix="step" default="false" type="step" display-label="STEP"/>
			<file output-prefix="iges" default="false" type="iges" display-label="IGES"/>
			<file output-prefix="dxf" default="false" type="dxf" display-label="DXF"/>
			<file output-prefix="cgm" default="false" type="cgm" display-label="CGM"/>
			<file output-prefix="pdf" default="false" type="pdf" display-label="pdf"/> 
		</additional-files>		

		<additional-files name="released_drawing">
			<!-- only default='true' files will be generated at this time -->
			<file output-prefix="dxf" default="true" type="dxf" display-label="DXF"/>
			<file output-prefix="pdf" default="true" type="pdf" display-label="pdf"/> 
		</additional-files>

		<condition name="do_not_publish">
			<and>
				<attribute name="epmdoc_lifeCycleState" value="Under Review"/>
			</and>
	</condition>
			
	<condition name="is_released_drawing">
			<and>
				<attribute name="epmdoc_CADName" regex=".*\.drw" />
				<or>
					<attribute name="epmdoc_lifeCycleState" value="Released"/>
					<attribute name="epmdoc_lifeCycleState" value="Uvolněno"/>
					<attribute name="epmdoc_lifeCycleState" value="Schvaleno"/>
				</or>
			</and>
	</condition>

		<if condition="do_not_publish">
		</if>
		
		<if condition="is_released_drawing">
			<publish on="checkin" display-label="Released Drawing" additional-files="released_drawing"/>
		 <publish on="create-representation" display-label="Released Drawing" additional-files="released_drawing" />
		 <publish on="schedule" display-label="Released Drawing" additional-files="released_drawing"/>
		 <publish on="unknown-source" display-label="Released Drawing" additional-files="released_drawing"/>
		</if>
		
		<publish additional-files="standard_files" on="checkin"/>
		<publish additional-files="standard_files" on="create-representation"/>
		<publish additional-files="standard_files" on="schedule" />
		<publish additional-files="standard_files" on="unknown-source" />
	</authoring-application> 
</rules>

 

PetrH