Personalización avanzada > Business Logic Customization > Customizing Windchill Visualization Services > Modifying the Default Behavior of Dynamic Part Generation
Modifying the Default Behavior of Dynamic Part Generation
Before a part structure can be viewed in Creo View, the representations associated to the parts selected by the navigation criteria must be merged into a single PVS file. The representations used to dynamically generate the PVS structure are the default representations of parts. If a part is associated to a CAD structure whose children do not have an associated WTParts with representations, the geometry for the part will not be viewable in Creo View.
Starting in Windchill 10.2 M010, it is now possible to change the default behavior of dynamic part structure generation by using a custom filter. The filter can be used to exclude parts, use representations other than the default representation associated to the part or to include the entire representation for an assembly instead of merging the representations associated to its children.
Creating a Custom Part Structure Filter
To modify the default behavior of the dynamic part filter, you must create a custom class that includes an API with the following signature: public static WTKeyedMap myFilterMethod(WTKeyedHashMap filterPartStructureParentMap, WTValuedMap representations)
Where:
filterPartStructureParentMap is a map of parts to it's WTPartUsage links
representations is a map of parts to their default representations
The return map is a WTKeyedMap of parts to the filter action to use for the part
The possible filter actions are:
RepStructureFilterAction. NORMAL: Normal processing. Do not do exclude or include the representation.
RepStructureFilterAction. EXCLUDE: Filter out this representation.
RepStructureFilterAction. INCLUDE_REP_AND_EXCLUDE_CHILDREN: Stop structure traversal but include the assembly representation.
RepStructureFilterAction. EXCLUDE_REP_AND_EXCLUDE_CHILDREN: Stop structure traversal and exclude the assembly representation.
To use a different representation than the default, the filter should replace the existing representation in the _representations map with the representation that should be used when viewing the part.
For examples of how to use the filter actions, see the example below or look at the examples in <WT_HOME>\ prog_examples\wvs\com\ptc\wvs\PartStructureFilter.java.
Configuration Details
Customers must configure the class name and method to use for the filter by setting the “edrload.partstructurefiltermethodwvs.property. The property must be set to a Class/Method. For example, if your class is located in “ext.custom.partstructure” and the name of the class is “PartStructureFilter” and the name of the method is “filterPartStructure”, the following entry should be added to site.xconf.
<Property name="edrload.partstructurefiltermethod" overridable="true" targetFile="codebase/wvs.properties" value=" ext.custom.partstructure. PartStructureFilter/filterPartStructure "/>
The modifications will not appear in the Windchill Visualization tab unless the following property is set to “true”.
<Property default="false" name="edrload.partstructurefilter.enableviztabfilter"/>
Example
Only parts in the released state should be shown in Creo View. Assembly representations in the release state should include the assembly representation and exclude the child representations.
/**
* This example filter can be used to include parts in the "released"
* state and exclude all others. End item parts are added to the
* return map as "NORMAL" and assemblies are added as
* "INCLUDE_REP_AND_EXCLUDE_CHILDREN".
* The result is that only released parts can be viewed.
*
* @param _root - The root node of the structure of the part being viewed.
* Not used in this example.
* @param _filterPartStructureParentMap - A map of parts to a set of
* WTPartUsageLink objects.
* Contains the structure of the part
* being viewed
* @param _representations - A map of parts to their default representation.
* Used to replace representations in
* the structure, not used in this example
*
* @return WTKeyedMap - A WTKeyedMap of parts to their
* RepStructureFilterAction enums
*/
public static WTKeyedMap useCase1(WTObject _root,
WTKeyedMap _filterPartStructureParentMap,
WTValuedMap _representations) {
WTKeyedHashMap retSet = new WTKeyedHashMap();
for(Iterator it=_filterPartStructureParentMap.entrySet().iterator(); it.hasNext();) {
WTKeyedMap.WTEntry entry = (WTKeyedMap.WTEntry)it.next();
try {
WTPart part = (WTPart)entry.getKeyAsPersistable();
String partName = part.getName();
logger.debug("Inside filterPartStructure,
Part Name == " + partName);

State state = part.getLifeCycleState();
// Only include parts in the "RELEASED" state
if (state.toString().equals("RELEASED")) {
// do include this representation
if (part.isEndItem())
retSet.put(part, RepStructureFilterAction.NORMAL);
// An end part
else
retSet.put(part, RepStructureFilterAction.
INCLUDE_REP_AND_EXCLUDE_CHILDREN); // An assembly
logger.debug("Adding " + partName + " to return map to be
included");
}
else {
// don't include this representation
retSet.put(part, RepStructureFilterAction.EXCLUDE);
logger.debug("Adding " + partName + " to return map to
be excluded");
}
}
catch (WTException e) {
logger.error("Error filtering parts in the
'partStructureFilter' hook:\n " + e);
}
}
return retSet;
}
¿Fue esto útil?