================ CODE SNIPPETS ================ TITLE: Basic Custom Command class DESCRIPTION: This VB.NET code snippet demonstrates the minimal setup for a SP3D API based Custom Command. It imports the necessary dependencies, and overrides and exposes the methods needed to define a Custom Command by inheriting from the `Ingr.SP3D.Common.Client.BaseModalCommand` class. Remarks that `OnStart` is the Custom Command's entrypoint, as they get compiled as .dll files. This illustrates the simplest way to define the structure of a Custom Command. LANGUAGE: VB.NET CODE: ``` Imports Ingr.SP3D.Common.Client Public Class CustomCommand Inherits BaseModalCommand Public Overrides ReadOnly Property EnableUIFlags() As Integer Get Return MyBase.EnableUIFlags EnableUIFlags = EnableUIFlagSettings.ActiveView End Get End Property Public Overrides Sub OnIdle() MyBase.OnIdle() End Sub Public Overrides Sub OnResume() MyBase.OnResume() End Sub Public Overrides Sub OnSuspend() MyBase.OnSuspend() End Sub Public Overrides Sub OnStop() MyBase.OnStop() End Sub ''' ''' The Custom Command starts here, this is the enty point ''' ''' ''' Public Overrides Sub OnStart(ByVal commandID As Integer, ByVal argument As Object) MyBase.OnStart(commandID, argument) End Sub ``` -------------------------------- TITLE: Define connection objects for the plant (necessary to edit it from a Custom Command) DESCRIPTION: This VB.NET code snippet demonstrates the way to get the neccesary `Ingr.SP3D.Common.Middle.Services.TransactionManager`, `Ingr.SP3D.Common.Middle.Services.Plant`, `Ingr.SP3D.Common.Middle.Services.Model`, `Ingr.SP3D.Common.Middle.Services.Catalog`, `Ingr.SP3D.Common.Middle.Services.SP3DConnection` and `Ingr.SP3D.Common.Middle.Services.CatalogBaseHelper` objects. It first imports the necessary dependencies, then, it gets the `TransactionManager` and `Plant` from the `MiddleServiceProvider` static class. After that, it also acquires the `Model` object from the `Plant`, and then it obtains the `Catalog` from it. This catalog gets copied and cast to a `SP3DConnection` object, and with this as a parameter, we can declare a `CatalogBaseHelper`. LANGUAGE: VB.NET CODE: ``` Imports Ingr.SP3D.Common.Middle.Services Dim oTransactionMgr As TransactionManager = MiddleServiceProvider.TransactionMgr oPlant = MiddleServiceProvider.SiteMgr.ActiveSite.ActivePlant oModel = oPlant.PlantModel Dim oCatalog As Catalog = oModel.PlantCatalog Dim oConn As SP3DConnection = oCatalog Dim oCatalogBaseHelper As New CatalogBaseHelper(oConn) ``` --------------------------------