Creating relationships with link interfaces - 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

Link interfaces are the SmartPlant Foundation Schema way of putting properties on relationships. RelDefs can be defined with a link interface, and that interface can expose properties. Once you have an IRel, since it exposes IObject, you then have access to the interfaces and properties. As an example, consider the RelDef SPFRelDefAccessGroup.

This relationship is defined with a link interface (ISPFRelDefAccessGroup) having several properties. To create this relationship with properties, the code would be as follows.

' Get the user and company

Dim lobjRelDef As IObject = Me.SPFSession.GetObjectByUID("PBSIemCollection", "IRelDef")

Dim lobjAccessGroup As IObject = Me.SPFSession.GetObjectByName("VIEWONLY", "ISPFAccessGroup")

' Create the rel

Dim lobjRel As IRel = SPF.Client.Schema.Utilities.CreateRel(Me.SPFSession, "SPFRelDefAccessGroup", lobjRelDef, lobjAccessGroup)

With lobjRel.IObject.Interfaces("ISPFRelDefAccessGroup")

.Properties("SPFRelExpand1to2").SetValue(True)

.Properties("SPFRelExpand2to1").SetValue(False)

.Properties("SPFRelDragDrop1on2").SetValue(True)

.Properties("SPFRelDragDrop2on1").SetValue(False)

.Properties("SPFRelTerminate").SetValue(True)

End With

The only unique bit of code here is the With block. The With block is not necessary, but if you are going to be repeatedly working with an object (in this case, the ISPFRelDefAccessGroup interface), then it is more efficient to set a reference to it in some way rather than to continually go through the Interfaces collection.