Patchwork 3D Community 2020.2 X4

Rule Syntax

Rule syntax is based on the following principles:

  • All rules have names.

  • All expressions are enclosed in parentheses.

  • All rules begin with an operator, followed by an operand.

Simple Rules

Simple rules are expressions using the "defined" operator only. This operator takes a single argument, a user-defined symbol, which follows it. The symbol is set off by a space and must be set inside double quotes.

Simple rules are written as:

Rule (defined "symbol")

A symbol can take the form "partition" or "partition.value_n". In the case of " partition.value_n " forms, multiple rules will have the same "partition." prefix.

Rule1(defined "partition1")

Rule2(defined "partition2")

Rule3(defined "partition3.value_1")

Rule4 (defined "partition3.value_2")

Rule5(defined "partition3.value_3")

Complex Rules

Complex rules are Boolean expressions. They can call on several of the operators available: the operator "defined" and the logical operators "and", "or", "not", "xor".

Each logical operator takes two arguments in any order. The arguments of the logical operators are expressions enclosed in parentheses and can be either the expression of a simple rule or the expression of another complex rule.

Operators are placed before operands in the Boolean expression. Nested parentheses indicate the grouping of expressions and their order of evaluation.

Rule(and (defined "symbol_p") (defined "symbol_q"))

This rule is true if symbol_p and symbol_q are defined.

Rule(or (defined "symbol_p") (defined "symbol_q"))

This rule is true if symbol_p or symbol_q is defined.

Rule(and (or (defined "symbol_p") (defined "symbol_q")) (defined "symbol_r"))

This rule is true if symbol_p or symbol_q is defined ("or" is evaluated first), and if symbol_r is also defined.