Relationship path specification

TypeScript type: RelationshipPathSpecification.

Relationship path specification is used to define a relationship path to an ECClass.

The specification is always used in a context where source class already exists, so it only requires the relationship and direction. The target class can be inferred from the two required attributes or specified with the targetClass attribute. In case of a multi-step path, target of the current step is used as the source of the next step.

Attributes

Name Required? Type Default
relationship Yes SingleSchemaClassSpecification
direction Yes "Forward" | "Backward"
targetClass No SingleSchemaClassSpecification Other end of the relationship

Attribute: relationship

This attribute specifies the ECRelationship that should be used to traverse to target class.

Type SingleSchemaClassSpecification
Is Required Yes

Attribute: direction

This attribute specifies the direction in which the relationship should be followed:

  • "Forward" - the relationship is traversed from source to target of the relationship.
  • "Backward" - the relationship is traversed from target to source of the relationship.
Type "Forward" | "Backward"
Is Required Yes

Attribute: targetClass

This attribute may be used to specialize the target of the relationship. E.g. when relationship points to a class like bis.Element, this attribute allows specializing it to bis.PhysicalElement or some other bis.Element subclass.

Type SingleSchemaClassSpecification
Is Required No
Default Value Target ECClass of the relationship if the direction is "Forward" or source ECClass if the direction is "Backward"

Examples

Using single-step relationship path

// This ruleset defines a specification that returns content for given `bis.Model` instances. The
// content is created for model elements found by following the `bis.ModelContainsElements`
// relationship and picking only `bis.PhysicalElement` type of elements.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      condition: `SelectedNode.IsOfClass("Model", "BisCore")`,
      specifications: [
        {
          specType: "ContentRelatedInstances",
          relationshipPaths: [
            {
              relationship: { schemaName: "BisCore", className: "ModelContainsElements" },
              direction: "Forward",
              targetClass: { schemaName: "BisCore", className: "PhysicalElement" },
            },
          ],
        },
      ],
    },
  ],
};
Input Result
bis.PhysicalModel instance Result when input is bis physical model instance
bis.DefinitionModel instance Results when input is bis definition model instance

Using multi-step relationship path

// This ruleset defines a specification that returns content for given `bis.GeometricModel3d` instances. The
// content is created for categories of model elements found by following the `bis.ModelContainsElements` and
// `bis.GeometricElement3dIsInCategory` relationships.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      condition: `SelectedNode.IsOfClass("GeometricModel3d", "BisCore")`,
      specifications: [
        {
          specType: "ContentRelatedInstances",
          relationshipPaths: [
            [
              {
                relationship: { schemaName: "BisCore", className: "ModelContainsElements" },
                direction: "Forward",
              },
              {
                relationship: { schemaName: "BisCore", className: "GeometricElement3dIsInCategory" },
                direction: "Forward",
              },
            ],
          ],
        },
      ],
    },
  ],
};

Categories of input model elements

Last Updated: 03 April, 2024