CustomPartBase Class

The CustomPartBase class is a base class for defining custom parts. These types are more specialized and restricted by the input values than the ones derived from PluginBase.

The coordinate system for connections, details and seams is explained in the Tekla Structures help, in the part about the position type of custom components. The position type defines the origin of the custom component, relative to the main part.

Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    Tekla.Structures.PluginsCustomPartBase

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

The CustomPartBase type exposes the following members.

Properties
  NameDescription
Public propertyIdentifier
The identifier of the executable plug-in instance.
Public propertyPositions
The positional attributes for a custom part instance.
Top
Methods
  NameDescription
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 component. Inside Run the user can implement the logic based on the user given attributes and input. Inside the method input can be found from the provided properties: Primary, Secondaries and Positions.
Top
Examples
In the following example, a .inp file is used for defining the dialog. Notice that starting from version 15.0, the System.Windows.Forms namespace can be used to create rich user interfaces. See e.g. the PluginFormBase class in the Tekla.Structures.Dialog documentation for more information.
using System;
using System.Windows.Forms;

using Tekla.Structures.Model;
using Tekla.Structures.Plugins;
using Tekla.Structures.Geometry3d;

public class StructuresData3
{
    [StructuresField("P1")]
    public double Parameter1;
    [StructuresField("P2")]
    public string Parameter2;
}

[Plugin("CustomBeam")] // The name of the connection in the catalog
[PluginUserInterface(UserInterfaceDefinitions.Plugin3)]
public class CustomBeam: CustomPartBase
{
    private readonly StructuresData3 data;

    public CustomBeam(StructuresData3 data)
    {
        this.data = data;
    }

    static Beam CreateBeam(Point point1, Point point2, string profile)
    {
        Beam myBeam = new Beam(point1, point2);
        myBeam.Profile.ProfileString = profile;
        myBeam.Finish = "PAINT";
        myBeam.Position.Depth = Position.DepthEnum.MIDDLE;
        myBeam.Position.Plane = Position.PlaneEnum.RIGHT;
        myBeam.Insert();
        return myBeam;
    }

    static void CreateFitting(double thickness, Beam myPart)
    {
        Fitting myFitting = new Fitting();
        myFitting.Plane.Origin = new Point(thickness, 0, 0);
        myFitting.Plane.AxisX = new Vector(0, 1000, 0);
        myFitting.Plane.AxisY = new Vector(0, 0, 1000);
        myFitting.Father = myPart;

        myFitting.Insert();
    }

    public override bool Run()
    {
        try
        {
            // The default values
            if(IsDefaultValue(data.Parameter1))
                data.Parameter1 = 300.0;
            if (IsDefaultValue(data.Parameter2))
                data.Parameter2 = "PL10*300";

            // Get input points
            Point point1 = new Point(this.Positions[0]);
            Point point2 = new Point(this.Positions[1]);
            if (data.Parameter1 > 0)
            {
                point1.Y -= data.Parameter1 / 2;
                point2.Y += data.Parameter1 / 2;
            }

            Beam newBeam = CreateBeam(point1, point2, data.Parameter2);

            double thickness = 0.0;
            newBeam.GetReportProperty("PROFILE.WIDTH", ref thickness);
            CreateFitting(thickness, newBeam);
        }
        catch(Exception e)
        {
            MessageBox.Show(e.ToString());
        }

        return true;
    }

    public class UserInterfaceDefinitions 
    {
        public const string Plugin3 = @"" +
        @"page(""TeklaStructures"","""")" + "\n" +
        "{\n" +
        "    joint(1, BeamConnection)\n" +
        "    {\n" +
        @"        tab_page(""Beam test"", ""Parameters"", 1)" + "\n" +
        "        {\n" +
        @"            parameter(""Plate Length"", ""P1"", distance, number, 1)" + "\n" +
        @"            parameter(""Profile"", ""P2"", profile, text, 2)" + "\n" +
        "        }\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.
Previous
Next