The part selection rule automatically returns an appropriate part based on the input selection criteria. For example, when you place a design support on a 6 inch pipe and trigger Add Part command to select a Pipe Clamp from the main node of the part class, the software uses the Part Selection Rule to find an appropriate pipe clamp that can be placed on a 6 inch pipe.
To create a new part selection rule in .NET:
-
use the SupportPartSelectionRule base class
-
the class that you use must inherit from SupportPartSelectionRule
To create a new Part Selection Rule in Microsoft Visual Basic, implement IJHgrPartSelectionRule.
SelectedPartFromPartClass
The SelectedPartFromPartClass method of the SupportPartSelectionRule class decides on a part to return based on the input selection. The following method returns a part based on the input selection.
public override Part SelectedPartFromPartClass(string sPartClass)
{ return selectedPart; }
The following code sample illustrates implementation of SelectedPartFromPartClass method:
//----------------------------------------------------------------------
//This Rule returns part when pipe size is equal.
//----------------------------------------------------------------------
public class PartByPipeSizeEqual : SupportPartSelectionRule
{
public override Part SelectedPartFromPartClass(string sPartClass)
{
Part selectedPart = null;
PipeObjectInfo pipe = (PipeObjectInfo)SupportedHelper.SupportedObjectInfo(1);
// Method SupportPartBySize(), takes PartClass name as input and compares the system defined attributes like NominalDiameter with the Operator type mentioned in next input like NDFrom_EQUAL.
// the returned type is Part
selectedPart= SupportPartBySize(sPartClass, pipe.NominalDiameter, NDComparisonOperatorType.NDFrom_EQUAL);
return selectedPart;
}
}