高度なカスタマイズ > ビジネスロジックのカスタマイズ > Windchill Visualization Services のカスタマイズ > 動的な部品生成のデフォルト動作の修正
  
動的な部品生成のデフォルト動作の修正
部品構造を Creo View で表示できるようにするには、まず、ナビゲーション基準によって選択された部品に関連付けられた製品表現を、単一の PVS ファイルにマージする必要があります。PVS 構造の動的な生成に使用される製品表現は、部品のデフォルトの製品表現です。子の WTParts が製品表現に関連付けられていない CAD 構造に部品を関連付けた場合、その部品のジオメトリは Creo View に表示されません。
Windchill 10.2 M010 以降、カスタムフィルタを使用して、動的な部品構造を生成するためのデフォルト動作を変更できるようになりました。このフィルタを使用して、部品を除外したり、部品に関連付けられたデフォルトの製品表現以外の製品表現を使用したり、あるいは、アセンブリの子に関連付けられた製品表現をマージするのではなくアセンブリ全体の製品表現を含めたりすることができます。
カスタム部品構造フィルタの作成
動的な部品フィルタのデフォルト動作を修正するには、次の署名の付いた API を含むカスタムクラスを作成する必要があります。public static WTKeyedMap myFilterMethod(WTKeyedHashMap filterPartStructureParentMap, WTValuedMap representations)
ここで、
filterPartStructureParentMap は、部品の WTPartUsage リンクへのマッピングです。
representations は、部品のデフォルト製品表現へのマッピングです。
戻り Map 値は、部品に対して使用するフィルタ操作への部品の WTKeyedMap です。
使用可能なフィルタ操作は次のとおりです。
RepStructureFilterActionNORMAL: 通常の処理。製品表現を除外したり含んだりすることはできません。
RepStructureFilterActionEXCLUDE: この製品表現をフィルタで除外します。
RepStructureFilterActionINCLUDE_REP_AND_EXCLUDE_CHILDREN: 構造のトラバースを停止しますが、アセンブリの製品表現を含めます。
RepStructureFilterActionEXCLUDE_REP_AND_EXCLUDE_CHILDREN: 構造のトラバースを停止し、アセンブリの製品表現を除外します。
デフォルトとは異なる製品表現を使用するには、フィルタによって、_representations マップ内の既存の製品表現を、部品を表示するときに使用する製品表現に置き換える必要があります。
フィルタ操作の使用方法の例については、後述の例を参照するか、<WT_ホーム>\prog_examples\wvs\com\ptc\wvs\PartStructureFilter.java にある例を確認してください。
コンフィギュレーションの詳細
"edrload.partstructurefiltermethod" wvs.property を設定することで、フィルタに使用するクラス名とメソッドを設定する必要があります。プロパティをクラス/メソッドに設定する必要があります。たとえば、クラスが "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;
}