修改动态零件生成的默认行为
在可于 Creo View 中查看部件结构之前,必须将通过导航条件选择的与部件相关联的表示合并到单个 PVS 文件中。用于动态生成 PVS 结构的表示是部件的默认表示。如果部件与 CAD 结构关联且该 CAD 结构的子项没有与表示关联的 WTParts,则该部件的几何将无法在 Creo View 中查看。
Windchill 10.2 M010 开始,现在可以通过使用自定义筛选器来更改动态部件结构生成的默认行为。筛选可用于排除部件、使用除关联至部件的默认表示之外的其他表示或者包括装配的整个表示,而非合并与其子项关联的表示。
创建自定义部件结构筛选器
要修改动态部件筛选器的默认行为,必须创建一个自定义类,其中应包含具有以下签名的 API:public static WTKeyedMap myFilterMethod(WTKeyedHashMap filterPartStructureParentMap, WTValuedMap representations)
其中:
filterPartStructureParentMap 是部件到其 WTPartUsage 链接的映射
representations 是部件到其默认表示的映射
返回映射是部件的 WTKeyedMap,适用于部件的筛选操作
可能的筛选器操作包括:
RepStructureFilterAction. NORMAL:正常处理。不执行排除或包括表示。
RepStructureFilterAction. EXCLUDE:筛选出此表示。
RepStructureFilterAction. INCLUDE_REP_AND_EXCLUDE_CHILDREN:停止结构遍历,但包括装配表示。
RepStructureFilterAction. EXCLUDE_REP_AND_EXCLUDE_CHILDREN:停止结构遍历并排除装配表示。
要使用不同于默认值的表示,筛选器应该将 _representations 映射中的现有表示替换为查看部件时应使用的表示。
有关如何使用筛选器操作的示例,请参阅下面的示例或查看 <WT_HOME>\prog_examples\wvs\com\ptc\wvs\PartStructureFilter.java 中的示例。
配置详细信息
客户必须通过设置 "edrload.partstructurefiltermethod" wvs.property 来配置用于筛选器的类名称和方法。必须将特性设置为 Class/Method。例如,如果类位于 "ext.custom.partstructure" 中,且类的名称为 "PartStructureFilter",方法的名称为 "filterPartStructure",则应将以下条目添加到 site.xconf 中。
<Property name="edrload.partstructurefiltermethod" overridable="true" targetFile="codebase/wvs.properties" value=" ext.custom.partstructure. PartStructureFilter/filterPartStructure "/>
除非将以下特性设置为 true,否则修改不会出现在 Windchill 可视化选项卡中。
<Property default="false" name="edrload.partstructurefilter.enableviztabfilter"/>
示例
只有处于已发布状态的部件才应显示在 Creo View 中。处于发布状态的装配表示应包括装配表示并排除子表示。
/**
* 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;
}
这对您有帮助吗?