Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Unified Engineering

Code examples for Special Case rules

  • Last UpdatedOct 15, 2026
  • 1 minute read

For special case rules, it is common to define a special purpose for the Rule Set (RLSET) and Design Rule (DRULE) to allow a database collection to find all the rulesets of the same type. In the example, Generative Design AI (GENDAI) pipe distance from plane rules are searched. These have a RLSET purpose of PDAI, and a DRULE purpose of RPDI.

!coll = object COLLECTION()

!coll.type('RLSET')

!coll.filter(object expression('DBTYP EQ |CATA| AND PURP EQ |PDAI|'))

!rlsets = !coll.results()

!rule = object DBREF()

if (!rlsets.size().gt(0)) then

-- Ideally, a user interface should be created so users can select

-- between rules.

-- For this example, we will select the first available.

!rules = !!collectAllFor('DRULE', 'PURP EQ |RPDI|', !rlsets[1])

if (!rules.size().gt(0)) then

!rule = !rules[1]

endif

endif

Having located a rule, it can be run for the current element using the EvaluateRule method.

In the following examples, the current element (!!ce) is the evaluating element. The element does not have a rule set reference available, so care must be taken to make sure the element is of the correct type for this rule. In this case, the pipe rule must be evaluated on a BRANCH element.

This method evaluates the rule for the current element:

if (!rule.badref().not() and !!ce.type.eq('BRAN')) then

!result = !rulesEngine.evaluateRule(!!ce.name, !rule.name)

endif

If the rule is executed successfully, the result string is set. For this piping rule,the expected result is a distance. If the rule fails to evaluate, the string is empty. It might fail if the element does not have the attributes necessary to evaluate the expressions in the rule.

Related Links