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. There is no new code to learn to deal with link interfaces, since a relationship is an object as well. See the following example:

Dim lobjRelIObj As IObject = GeneralUtilities.InstantiateRelation("SPFRelDefAccessGroup", lobjRelDef, lobjAccessGroup, False)

Dim lobjRelISPFRelDefAccessGroup As ISPFRelDefAccessGroup = CType(lobjRelIObj.Interfaces("ISPFRelDefAccessGroup", True), ISPFRelDefAccessGroup)

lobjRelISPFRelDefAccessGroup.SPFRelExpand1to2 = True

lobjRelISPFRelDefAccessGroup.SPFRelExpand2to1 = False

lobjRelISPFRelDefAccessGroup.SPFRelDragDrop1on2 = True

lobjRelISPFRelDefAccessGroup.SPFRelDragDrop2on1 = False

lobjRelISPFRelDefAccessGroup.SPFRelTerminate = True

lobjRelISPFRelDefAccessGroup.GetClassDefinition.FinishCreate(lobjRelISPFRelDefAccessGroup)

The first line of code is just creating the relationship like before. The second line of code, though, is used to get the link interface for that relationship. Here, we've used the Interfaces collection from IObject rather than the ToInterface method. This is because the ToInterface method will not create the interface if it does not already exist. The indexer on the Interfaces collection will return an IInterface that can be cast to the specialized interface we need. From there, it is just a matter of accessing the properties on the specialized interface.

Remember to call FinishCreate at the end.