Content instances of specific classes specification

TypeScript type: ContentInstancesOfSpecificClassesSpecification.

This specification creates content for all instances of specific ECClasses.

Attributes

Name Required? Type Default
Filtering
classes Yes MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[]
excludedClasses No MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[] []
handlePropertiesPolymorphically No boolean false
instanceFilter No ECExpression ""
onlyIfNotHandled No boolean false
Ordering
priority No number 1000
Content Modifiers
relatedProperties No RelatedPropertiesSpecification[] []
calculatedProperties No CalculatedPropertiesSpecification[] []
propertyCategories No PropertyCategorySpecification[] []
propertyOverrides No PropertySpecification[] []
Misc.
relatedInstances No RelatedInstanceSpecification[] []

Attribute: classes

Defines a set of multi schema classes that specify which ECClasses need to be selected to form the result.

Type MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[]
Is Required Yes
// The specification returns content of all `bis.PhysicalModel` classes.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["PhysicalModel"], arePolymorphic: false },
        },
      ],
    },
  ],
};

Example of using "classes" attribute

Attribute: excludedClasses

Defines a set of multi schema classes that prevents specified ECClasses and subclasses from being selected by classes attribute.

Type MultiSchemaClassesSpecification | MultiSchemaClassesSpecification[]
Is Required No
Default Value []
// The specification returns content of all classes derived from `bis.Model` except for excluded `bis.PhysicalModel` class.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["Model"], arePolymorphic: true },
          excludedClasses: { schemaName: "BisCore", classNames: ["PhysicalModel"] },
        },
      ],
    },
  ],
};
Result
excludedClasses: [] Example when doing normal class based instance select
excludedClasses as defined in the above ruleset Example when selecting instances with some classes excluded

Attribute: handlePropertiesPolymorphically

Specifies whether properties of derived classes should be included in the content.

Type boolean
Is Required No
Default Value false
// This ruleset returns content of all `bis.ViewDefinition` instances, including all properties from derived classes.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["ViewDefinition"], arePolymorphic: true },
          handlePropertiesPolymorphically: true,
        },
      ],
    },
  ],
};
Result
handlePropertiesPolymorphically: false Example when only selecting class specified properties
handlePropertiesPolymorphically: true Example when selecting parent and child class properties

Attribute: instanceFilter

Specifies an ECExpression for filtering instances of ECClasses specified through the classes attribute.

Type ECExpression
Is Required No
Default Value ""
// This ruleset returns content of all `bis.SpatialViewDefinition` instances whose `Pitch` property is greater or equal to 0.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["SpatialViewDefinition"] },
          instanceFilter: "this.Pitch >= 0",
        },
      ],
    },
  ],
};
Result
instanceFilter: "" Example when selecting all instances
instanceFilter as defined in the above ruleset Example when filtering instances

Attribute: onlyIfNotHandled

When true, the specification takes effect only when all other specifications with higher priority are ruled out. This attribute is most useful for defining fallback specifications.

Type boolean
Is Required No
Default Value false
// This ruleset defines two specifications that return content for `bis.ViewDefinition` and `bis.PhysicalModel`
// instances respectively.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["ViewDefinition"], arePolymorphic: true },
        },
        // The following specification is defined second so it's lower in priority. Because it has `onlyIfNotHandled` attribute,
        // it's overriden by the specification above.
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["PhysicalModel"], arePolymorphic: true },
          onlyIfNotHandled: true,
        },
      ],
    },
  ],
};
Result
onlyIfNotHandled: true Example using both specifications
onlyIfNotHandled: false Example with "only if not handled" specifications

Attribute: priority

Controls the order in which specifications are handled — specification with higher priority value is handled first. If priorities are equal, the specifications are handled in the order they appear in the ruleset.

Type number
Is Required No
Default Value 1000
// Specifications to return content for `bis.PhysicalModel` and `bis.DictionaryModel` respectively.
// The `bis.PhysicalModel` specification has lower priority so it's displayed after the
// higher priority specification.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["PhysicalModel"] },
          priority: 0,
        },
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["DictionaryModel"] },
          priority: 1,
        },
      ],
    },
  ],
};

Example of using "priority" attribute

Attribute: relatedProperties

Specifications of related properties which are included in the generated content.

Type RelatedPropertiesSpecification[]
Is Required No
Default Value []
// This ruleset returns content for `bis.SpatialViewDefinition`, which includes all properties from related `bis.DisplayStyle` instances.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["SpatialViewDefinition"] },
          relatedProperties: [
            {
              propertiesSource: {
                relationship: { schemaName: "BisCore", className: "ViewDefinitionUsesDisplayStyle" },
                direction: "Forward",
              },
            },
          ],
        },
      ],
    },
  ],
};
relatedProperties: [] relatedProperties as defined in the above ruleset
Example when doing normal property select Example when selecting with "related properties"

Attribute: calculatedProperties

Specifications of calculated properties whose values are generated using provided ECExpressions.

Type CalculatedPropertiesSpecification[]
Is Required No
Default Value []
// In addition to returning content for all `bis.SpatialViewDefinition` instances, this ruleset also adds a
// custom `Camera view direction` property to each instance.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["SpatialViewDefinition"] },
          calculatedProperties: [
            {
              label: "Camera view direction",
              value: 'IIf (this.pitch >= 10, "Vertical upwards", IIf (this.pitch <= -10, "Vertical downwards", "Horizontal"))',
            },
          ],
        },
      ],
    },
  ],
};

Example of using "calculated properties" attribute

Attribute: propertyCategories

Defines a list of custom categories.

Custom categories are not present in the result unless they contain at least one property. To assign a property to the category, reference its id in PropertySpecification.categoryId when defining propertyOverrides.

Type PropertyCategorySpecification[]
Is Required No
Default Value []
// This ruleset places camera-related `bis.SpatialViewDefinition` properties inside a custom category.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["SpatialViewDefinition"] },
          propertyCategories: [
            {
              id: "camera_category",
              label: "Camera settings",
              autoExpand: true,
            },
          ],
          propertyOverrides: [
            { name: "EyePoint", categoryId: "camera_category" },
            { name: "FocusDistance", categoryId: "camera_category" },
            { name: "IsCameraOn", categoryId: "camera_category" },
          ],
        },
      ],
    },
  ],
};

Example of using "property categories" attribute

Attribute: propertyOverrides

Specifications of various property overrides that allow customizing individual properties display.

Type PropertySpecification[]
Is Required No
Default Value []
// The specification returns content for `bis.ViewDefinition` with one
// overriden property label.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["ViewDefinition"], arePolymorphic: true },
          propertyOverrides: [{ name: "Model", labelOverride: "Container Model" }],
        },
      ],
    },
  ],
};
Result
propertyOverrides: [] Example when doing normal property select
propertyOverrides as defined in the above ruleset Example when selecting with "property overrides"

Attribute: relatedInstances

Specifications of related instances that can be used when creating the content. There are several use cases when this is useful:

  • When there's a need to only load instances that have a related instance. Providing a related instance specification with isRequired set to true filters-out the instances that don't have the related instance.

  • When there's a need to filter instances by a related instance value. The alias attribute may then be used in the instanceFilter attribute to reference related instance property values.

  • When there's a need to customize content based on related instance property values. Related instance classes are included when looking for customization rules, which allows referencing related instances and their properties in customization rule ECExpressions by their alias.

Type RelatedInstanceSpecification[]
Is Required No
Default Value []
// The specification returns content for `bis.ModelSelector` filtered by related
// `bis.SpatialViewDefinition` instance `Yaw` property value.
const ruleset: Ruleset = {
  id: "example",
  rules: [
    {
      ruleType: "Content",
      specifications: [
        {
          specType: "ContentInstancesOfSpecificClasses",
          classes: { schemaName: "BisCore", classNames: ["ModelSelector"], arePolymorphic: true },
          relatedInstances: [
            {
              relationshipPath: { relationship: { schemaName: "BisCore", className: "SpatialViewDefinitionUsesModelSelector" }, direction: "Backward" },
              alias: "relatedInstance",
            },
          ],
          instanceFilter: "relatedInstance.Yaw > 0",
        },
      ],
    },
  ],
};
Result
SpatialViewDefinition instances A list of spatial view definitions
ModelSelector instances A list of model selectors
ModelSelector instances filtered by SpatialViewDefinition.Yaw A list of model selectors filtered by yaw of related spatial view definition

Deprecated attributes

Attribute: handleInstancesPolymorphically

Tells whether selecting instances from ECClasses specified in classes and excludedClasses attributes should be polymorphic or not.

The attribute was replaced by MultiSchemaClasses.arePolymorphic attribute specified individually for each class definition under classes and excludedClasses attributes. At the moment, to keep backwards compatibility, this attribute acts as a fallback value in case the flag is not specified individually for a class definition.

Type boolean
Is Required No
Default Value false

Attribute: showImages

Should image IDs be calculated for the returned instances. When true, ImageIdOverride rules get applied when creating the content.

ExtendedDataRule should be used instead to provide image data to content items created by this specification. See extended data usage page for more details

Type boolean
Is Required No
Default Value false

Last Updated: 03 April, 2024