Example
Consider, for example, the machining process group in aPriori starting point VPEs. The process routing template node Rotational has an associated pruning module. This module eliminates all turning routings for parts that have no valid turning axis.
Here is a simplified version of this file:
 
Rule HasTurningAxes: (countTurningAxes > 0)
Message HasTurningAxes: 'PRUNE: ' + _
'Skip Turning Routings: this part has no turning axes and would not benefit.'
 
// Total count of turning axes extracted
countTurningAxes = _
select count(x) from part.childArtifacts x where isTurningAxis(x)
 
This module has one rule and one function definition.
The function uses a query to count the current part’s turning axes. The query effectively forms the set of child GCDs that are turning axes, and then returns the number of elements in that set. The query is composed of these expressions:
count(x): Query aggregate function (see Query Expressions in CSL chapter) that returns the number of elements in the collection formed by the query.
part.childArtifacts: Object access that uses the childArtifacts attribute of the current part (designated by the standard CSL input part) to retrieve the collection of the current part’s child GCDs.
isTurningAxis(x): builtin CSL function that returns true if the specified GCD is a turning axis; returns false otherwise. This filters the child GCDs, so that only those that are turning axes are included in the collection formed by the query.
The rule tests whether the function result (the number of turning axes that are child GCDs of the current part) is greater than 0. If the rule evaluates to true, the Rotational node is retained in the template, and the cost engine generates the routing that it (and its descendents) represent. If the rule evaluates to false, the Rotation node (together with all its descendents) is pruned, and the cost engine never generates the individual routings that it represents.