Integration with Other Applications > Managing CAD and Part Relationships in Windchill > Customizing Auto Associate > Using and Modifying the AutoAssociatePartFinderCreator Interface
Using and Modifying the AutoAssociatePartFinderCreator Interface
Auto Associate uses the implementation of the AutoAssociatePartFinderCreator interface to perform the following actions.
Search for a matching part.
Create a new part.
By default, the Auto Associate action uses the default implementation of this interface to perform the above-mentioned tasks. However, you can customize how they are performed using a customized implementation of the AutoAssociatePartFinderCreator interface.
The interface is located in com.ptc.windchill.cadx.autoassociate.AutoAssociatePartFinderCreator.
The AutoAssociatePartFinderCreator interface supports the following methods:
findOrCreateWTPart method used to search for matching part for a selected EPMdocument or ModelItem
CreateNewWTPart method used to create new part
findWTPart method (no longer used)
isNewPart method (no longer used)
setIsNewPart method (no longer used
)
* 
Even though some methods of the interface are deprecated and no longer used, the implementation class must have dummy implementations of these methods in order to compile the class.
To implement a customized AutoAssociatePartFinderCreator:
1. Derive your customized class as follows.
public class CustomFinderCreator implements
AutoAssociatePartFinderCreator
2. Override the following methods.
public WTPart findOrCreateWTPart(EPMDocument epmDoc, EPMWorkspace workspace)
This method is invoked for each document selected for auto-associate to search for any matching part. You can customize the criteria used to search the part, and the returned part is used by the action to associate to the document.
public WTPart findOrCreateWTPart(EPMDocument doc, ModelItem modelItem, EPMWorkspace workspace)
This method is invoked for each document selected for auto-associate to search for any matching part. You can customize the criteria used to search the part, and the returned part is used by the action to associate to the document.
public WTPart createNewWTPart(AssociatePartDescriptor newPartDescriptor)
This method is invoked for each document selected for auto-associate to create a new part. You can customize the properties of the newly created part. The newly created part is associated to the document by the auto-associate action.
* 
The following methods are deprecated and not currently used by the action; however, you need to provide a dummy implementation of these methods to compile the class properly.
public boolean isIsNewPart()
public void setIsNewPart(boolean a_IsNewPart)
public WTPart findWTPart(EPMDocument epmDoc)
public WTPart findWTPart(EPMDocument epmDoc, ModelItem modelItem)
Compile the file and place the class in any appropriate location.
3. Set the preference Operation > Auto Associate > Custom Class for Auto Associate Part to specify the name of the class that implements AutoAssociatePartFinderCreator interface.
4. Restart the method server.
Customized Auto Associate Part Finder Creator Example
Create and compile <WT_HOME>src\com\ptcts\autoassociate\CustomizedAutoAssociatePartFinderCreator.java with the following source.
// package com.ptc.windchill.uwgm.cadx.autoassociate;
package com.ptcts;

import java.lang.String;
import wt.epm.EPMDocument;
import wt.epm.workspaces.EPMWorkspace;
import wt.part.WTPart;
import wt.pom.UniquenessException;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.VersionControlException;
// import com.ptc.windchill.uwgm.task.autoassociate.DefaultAutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.autoassociate.DefaultAutoAssociatePartFinderCreator;
// import com.ptc.windchill.cadx.autoassociate.AutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.autoassociate.AutoAssociatePartFinderCreator;
import wt.type.TypedUtilityServiceHelper;
import com.ptc.windchill.uwgm.common.associate.AssociatePartDescriptor;
import wt.inf.container.WTContainer;
import java.rmi.RemoteException;

public class CustomizedAutoAssociatePartFinderCreator extends DefaultAutoAssociatePartFinderCreator implements AutoAssociatePartFinderCreator
{

public boolean isIsNewPart()
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: isIsNewPart()");
return super.isIsNewPart();
}

public void setIsNewPart( boolean a_IsNewPart ) throws WTPropertyVetoException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: setIsNewPart()");
super.setIsNewPart(a_IsNewPart);
}

public WTPart findOrCreateWTPart(EPMDocument epmDoc, EPMWorkspace workspace) throws WTException, WTPropertyVetoException, VersionControlException, UniquenessException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: findOrCreateWTPart()");
return super.findOrCreateWTPart(epmDoc, workspace);
}

public WTPart findWTPart(EPMDocument epmDoc) throws WTException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: findWTPart()");
return super.findWTPart(epmDoc);
}

public WTPart createNewWTPart(AssociatePartDescriptor newPartDescriptor) throws WTException, WTPropertyVetoException {

System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator :: createNewWTPart()");

// get epmdoc
EPMDocument epmDoc = newPartDescriptor.getSourceDoc();

// get workspace
EPMWorkspace ws = newPartDescriptor.getEPMWorkspace();

// get workspace container
WTContainer container = ws.getContainer();

// create wtpart with super class
WTPart newpart = super.createNewWTPart(newPartDescriptor);

// manipulate new part, e.g. set attributes

// return modified new part
return newpart;
}

}
Was this helpful?