Writing the Client API class - 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

Create a class with the exact name you want to use as the Client API.

Public Class DoSomething

Inherits SPF.Client.APIs.Model.ClientAPI

End Class

At a minimum, your Client API class must contain two methods. A constructor is required as follows.

Sub New(ByRef pobjClientAPICollection As SPF.Client.APIs.Model.ClientAPICollection)

MyBase.New(pobjClientAPICollection, True)

End Sub

The main execution point for the Client API is the ExecuteAPI method, so you need to implement this as well.

Protected Overrides Sub ExecuteAPI()

' The actual client API code goes here.

End Sub

Of course, you can implement as many worker properties and methods as you need to for the job at hand. But here is the minimum code for a Client API class:

Public Class DoSomething

Inherits SPF.Client.APIs.Model.ClientAPI

Sub New(ByRef pobjClientAPICollection As SPF.Client.APIs.Model.ClientAPICollection)

MyBase.New(pobjClientAPICollection, True)

End Sub

Protected Overrides Sub ExecuteAPI()

End Sub

End Class

Temporarily, to prove that our Client API is invoked, just add some code into the ExecuteAPI method to pop up the standard message box.

Protected Overrides Sub ExecuteAPI()

System.Windows.Forms.MessageBox.Show("Something has been done.", "Do Something", Windows.Forms.MessageBoxButtons.OK)

End Sub

Once you get your class written, build the project and correct any compile-time errors that are found.