Calculated properties specification
TypeScript type: CalculatedPropertiesSpecification.
This content modifier allows including additional calculated properties into the content.
Attributes
| Name | Required? | Type | Default | 
|---|---|---|---|
| label | Yes | string | |
| value | Yes | ECExpression | |
| priority | No | number | 1000 | 
Attribute: label
Specifies label of the calculated property. Supports localization.
| Type | string | 
| Is Required | Yes | 
// There's a content rule for returning content of given `bis.Subject` instance. The produced content is customized to
// additionally have a calculated "My Calculated Property" property.
const ruleset: Ruleset = {
  id: "example",
  rules: [{
    ruleType: "Content",
    specifications: [{
      specType: "SelectedNodeInstances",
      calculatedProperties: [{
        label: "My Calculated Property",
        value: `123`,
      }],
    }],
  }],
};

Attribute: value
Defines an expression to calculate the value. The expression can use ECInstance and Ruleset Variables symbol contexts.
| Type | ECExpression | 
| Is Required | Yes | 
// There's a content rule for returning content of given `bis.GeometricElement3d` instance. The produced content is
// customized to additionally have a calculated "Element Volume" property whose value is calculated based on
// element's `BBoxHigh` and `BBoxLow` property values.
const ruleset: Ruleset = {
  id: "example",
  rules: [{
    ruleType: "Content",
    specifications: [{
      specType: "SelectedNodeInstances",
      calculatedProperties: [{
        label: "Element Volume",
        value: "(this.BBoxHigh.x - this.BBoxLow.x) * (this.BBoxHigh.y - this.BBoxLow.y) * (this.BBoxHigh.z - this.BBoxLow.z)",
      }],
    }],
  }],
};

Attribute: priority
Assign a custom Field.priority to the property. It's up to the UI component to make sure that priority is respected - properties with higher priority should appear before or above properties with lower priority.
| Type | number | 
| Is Required | No | 
| Default Value | 1000 | 
// There's a content rule for returning content of given `bis.Subject` instance. The produced content is customized to
// additionally have a "My Calculated Property" property with priority set to `9999`. This should make the property
// appear at the top in the UI, since generally properties have a priority of `1000`.
const ruleset: Ruleset = {
  id: "example",
  rules: [{
    ruleType: "Content",
    specifications: [{
      specType: "SelectedNodeInstances",
      calculatedProperties: [{
        label: "My Calculated Property",
        value: `123`,
        priority: 9999,
      }],
    }],
  }],
};
| priority: 9999 | priority: -9999 | 
|---|---|
|  |  | 
Last Updated: 20 June, 2023