Child Rules

A Child Rule is a special rule that defines a child within a design. When a child rule is evaluated, it causes one or more child parts to be instantiated. Child rules do not need a data type specification; they are either of type Part or List type depending on the optional Quantity specification.

Syntax

Child <name> As <DesignNameExpression> [, <Quantity = Expression>]
   <ParameterAssignmentList>
End Child

When a child rule is evaluated, only the design name expression and the quantity expression are evaluated. The parameter assignment expressions are not evaluated in any way until the parameters are demanded. The parameter assignment list is not a statement block, and may not contain flow-of-control statements.

Note: It is not an error to assign to non-parameters or even identifiers which are not rules in the child.

The following example shows the syntax of a child rule.

Note: You cannot declare local variables in a child rule.

Design Name Expression

The design name expression must return the name of a valid design. The simplest expression uses a colon + identifier (such as :SquareTube) to return a name. The design name can also be specified by a more complex expression. This expression is evaluated before the child exists, so it cannot refer to anything inside the child, unlike parameter assignments.

Quantity Expression

An optional Integer value, Quantity, if present, indicates that the rule is a Child List (see Child Lists), even if the Quantity expression evaluates to 1. Without the Quantity specification, the child rule is of type Part .

Parameters in Child Rules

Parts can be modified by changing parameter values. If more two parts with different configurations are required, two separate child rules are written. Below, both the Support and crossMember children are instances of the :SquareTube design. Different values are specified in each child for the cut2 and length parameters.

Child Support As :SquareTube
   size = tubingSize
   cut1 = 0
   cut2 = 1
   length = height - footThickness
End Child
Child crossMember As :SquareTube
   size = tubingSize
   cut1 = 0
   cut2 = 0
   length = width - (tubingSize * 2)
End Child

Supported Flags

The only flag supported with child rules is Fixed. The Fixed flag indicates that the rule cannot be dynamically overridden. Attempts to add a dynamic rule by the same name will generate an error.