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

We are happy to announce the new Windchill Customization board! Learn more.

How to prohibit publishing of CAD documents based on name

khimani_mohiki
14-Alexandrite

How to prohibit publishing of CAD documents based on name

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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>

  

View solution in original post

6 REPLIES 6

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? 

TomU
23-Emerald IV
(To:khimani_mohiki)

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

 

khimani_mohiki
14-Alexandrite
(To:TomU)

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.

TomU
23-Emerald IV
(To:khimani_mohiki)

This is a 'publish filter'.  Read more about them here:

https://support.ptc.com/help/windchill/wc110_hc/whc_en/#page/Windchill_Help_Center%2FWCCG_BusLogicCust_WCVisualization_CustPublish_FilterAllPublishing.html

 

Turning it on requires updating a property in Windchill.  In my case I'm using positioning assemblies, so I'm using one of the hooks specific to those.  (There is some other 'stuff' related to positioning assemblies that I'm not showing since it shouldn't apply to what you're trying to do.)

- Compile filter:
tools class -Dclass.includes=ext\TMPublishHelper.java

- Turn on filter:
xconfmanager -s publish.positioningassembly.filtermethod=ext.TMPublishHelper/shouldPublishEPMDoc -t /codebase/WEB-INF/conf/wvs.properties -p

 

khimani_mohiki
14-Alexandrite
(To:TomU)

Hi Tom, I found a way to filter by name using the publishrules.xml

 

I created several conditions to match the different type of naming patterns, then some "if" statements to determine whether they should publish on checkin, schedule or when creating representations manually.

 

For me, not understanding java yet, this solution was actually quite easy to implement and changing the rules can be done by just uploading a different publishrules.xml , I even managed to add some publishing of additional files based on the conditions., a sort of fringe benefit. Although Im sure I could have done a lot more with a java based solution.

 

I will post the publishrules.xml later

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>

  

Top Tags