Related items and related item properties - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

Example 1. You can add criteria to navigate from one object to another related object, such as to link a folder to a specific plant.

lobjDynamicQuery.Query.Criteria = ObjectCriteria(Function(o)

o.HasInterface("ISPFFolder") And o.RelatedItem("+SPFFolderPlantItem", Function(ri) ri.Name = "PlantA"))

You specify the direction you want to navigate for the relationship by adding a plus + or minus - to the start of the relationship definition UID.

Example 2. You can navigate using edges.

lobjDynamicQuery.Query.Criteria = ObjectCriteria(Function(o)

o.HasInterface("ISPFDocumentVersion") And o.RelatedItem("EDG_VersionClassification",

Function(ri) ri.Name = " Adapter Document"))

Example 3. You can build up more complicated criteria for the objects on the end of the relationship or edge definition, such as for a specific interface on the object on the end of the relationship.

lobjDynamicQuery.Query.Criteria = ObjectCriteria(Function(o) o.RelatedItem("-SPFObjClassClassDef",Function(ri1) ri1.HasInterface("ISPFObjClass")))

Example 4. You can build up queries on your main target, as well as the objects on the end of the relationship.

lobjDynamicQuery.Query.Criteria = ObjectCriteria.(Function(o) o.Name = "*e*" And

o.RelatedItem("-SPFObjClassClassDef",Function(ri1) ri1.HasInterface("ISPFObjClass") And ri1.Name = "*g*"))

This query is defined from the main query section, where the name contains “e”. The criteria on the related object is defined after the RelatedObjectCrit eria. This includes the interface ISPFObjClass and the property name equals “g”.

Example 5.You can also break out the related object criteria section, as shown in the previous examples. The two lines return the same result, but can make the intention clearer.

Dim lobjRelatedItemCriteria As New ObjectCriteria(Function(ri) ri.HasInterface("ISPFObjClass") And ri.Name = "*g*")

lobjDynamicQuery.Query.Criteria = ObjectCriteria(Function(o) o.Name = "*e*" And

o.RelatedItem("-SPFObjClassClassDef", lobjRelatedItemCriteria))