PluginBase Class

The PluginBase class in an abstract base class for model plug-ins. Model plug-ins have to be inherited from this class. Drawing plug-ins have to be inherited from the DrawingPluginBase.

A plug-in is always executed in the plug-in's local coordinate system. The origin of the plug-in's coordinate system is defined based on the first input object or point. In case the first input is an object, the origin of the plug-in's coordinate system is the first input point of the object. In case the first input is a point, the origin of the plug-in's coordinate system is the input point. The X- and Y-axes of the coordinate system are defined in the current plane.

Inheritance Hierarchy

Namespace:  Tekla.Structures.Plugins
Assembly:  Tekla.Structures.Plugins (in Tekla.Structures.Plugins.dll) Version: 2023.0.3
public abstract class PluginBase : MarshalByRefObject

The PluginBase type exposes the following members.

Public propertyIdentifier
The identifier of the executable plug-in instance.
Public methodDefineInput
The method Tekla Structures calls for the plug-in to query the input. The plug-in must then return a list of input definition instances. The plug-in will be dependent on the items it returns. Dependent means that if any of these items change, for example the user moves the points, the plug-in will be re-run with new input. DefineInput is not called during the re-run, and thus all the actual implementation should be in the Run() method. The maximum number of InputDefinitions in the List is 10.
Public methodInitializeLifetimeService
Initializes the lifetime service.
(Overrides MarshalByRefObjectInitializeLifetimeService.)
Public methodIsDefaultValue(Double)
Returns true if the given value is set to the default value for this type.
Public methodIsDefaultValue(Int32)
Returns true if the given value is set to the default value for this type.
Public methodIsDefaultValue(String)
Returns true if the given value is set to the default value (empty string).
Public methodRun
The main method of the plug-in. It is called after the input has been defined with DefineInput(). This is the "main" method of the plug-in and should contain all the actual implementation.
In the following example a .inp file is used for defining the dialog, because the designer code of the form is too large to present here. See this same plug-in implemented with Windows Forms in the Examples of the Start-Up package. The System.Windows.Forms namespace can be used starting from version 15.0. See the PluginFormBase class in the Tekla.Structures.Dialog documentation for more information.
using System;
using System.Collections.Generic;
using Tekla.Structures.Plugins;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model.UI;
using TSM = Tekla.Structures.Model;

public class StructuresData 
       public double Parameter1;

[Plugin("BeamPlugin")] // Mandatory field which defines that this is the plug-in and stores the name of the plug-in to the system.
[PluginUserInterface(BeamPlugin.UserInterfaceDefinitions.Plugin1)] // Mandatory field which defines the user interface the plug-in uses. A Windows Forms class or a .inp file.
public class BeamPlugin: PluginBase
       private readonly StructuresData data;

       // The constructor argument defines the database class StructuresData and sets the data to be used in the plug-in.
       public BeamPlugin(StructuresData data)
           TSM.Model M = new TSM.Model();
  = data;

       //Defines the inputs to be passed to the plug-in.
       public override List<InputDefinition> DefineInput()
           Picker BeamPicker = new Picker();
           List<InputDefinition> PointList = new List<InputDefinition>();

           Point Point1 = BeamPicker.PickPoint();
           Point Point2 = BeamPicker.PickPoint();

           InputDefinition Input1 = new InputDefinition(Point1);
           InputDefinition Input2 = new InputDefinition(Point2);

           return PointList;

       //Main method of the plug-in.
       public override bool Run(List<InputDefinition> Input)
               Point Point1 = (Point)(Input[0]).GetInput();
               Point Point2 = (Point)(Input[1]).GetInput();
               Point LengthVector = new Point(Point2.X - Point1.X, Point2.Y - Point1.Y, Point2.Z - Point1.Z);

               if(data.Parameter1 > 0)
                   Point2.X = data.Parameter1 * LengthVector.X + Point1.X;
                   Point2.Y = data.Parameter1 * LengthVector.Y + Point1.Y;
                   Point2.Z = data.Parameter1 * LengthVector.Z + Point1.Z;

               CreateBeam(Point1, Point2);

           return true;

       static void CreateBeam(Point Point1, Point Point2)
           TSM.Beam MyBeam = new TSM.Beam(Point1, Point2);

           MyBeam.Profile.ProfileString = "HEA400";
           MyBeam.Finish = "PAINT";

       //.inp file user interface definition, check the Start-Up package for the Windows Forms dialog presentation.
       public class UserInterfaceDefinitions
           public const string Plugin1 = @"" +
           @"page(""TeklaStructures"","""")" + "\n" +
            "{\n" +
            "    plugin(1, BeamPlugin)\n" +
            "    {\n" +
           @"        tab_page(""Beam test"", ""Parametri_1"", 1)" + "\n" +
            "        {\n" +
           @"            parameter(""Length factor"", ""P1"", distance, number, 1)" + "\n" +
            "        }\n" +
            "    }\n" +

See Also
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.