ConnectionBase Class |
The ConnectionBase class is a base class for defining connections, details and seams.
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
Namespace: Tekla.Structures.Plugins
Assembly: Tekla.Structures.Plugins (in Tekla.Structures.Plugins.dll) Version: 2023.0.3
Syntax
The ConnectionBase type exposes the following members.
Properties
Name | Description | |
---|---|---|
Code |
The connection code of the executable connection instance. The maximum length is 22 characters.
| |
Identifier |
The identifier of the executable plug-in instance.
| |
Positions |
The positional attributes for a detail or a seam instance; one for a detail, N for a seam.
| |
Primary |
The identifier that was selected as the primary object.
| |
Secondaries |
A list of secondary identifiers of a connection or a seam.
|
Methods
Name | Description | |
---|---|---|
IsDefaultValue(Double) |
Returns true if the given value is set to the default value for this type.
| |
IsDefaultValue(Int32) |
Returns true if the given value is set to the default value for this type.
| |
IsDefaultValue(String) |
Returns true if the given value is set to the default value (empty string).
| |
Run |
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.
|
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. When using System.Windows.Forms,
the name of the form has to be the same one as the connection name for ConnectionBase, otherwise
the form will be loaded and shown but the apply method won't work (modify will work).
using System; using System.Windows.Forms; using Tekla.Structures; using Tekla.Structures.Plugins; using Tekla.Structures.Geometry3d; using Tekla.Structures.Model; public class StructuresData3 { [StructuresField("P1")] public double Parameter1; [StructuresField("P2")] public string Parameter2; } [Plugin("BeamConnection")] // The name of the connection in the catalog [PluginUserInterface(UserInterfaceDefinitions.Plugin3)] [SecondaryType(SecondaryType.SECONDARYTYPE_ONE)] [AutoDirectionType(AutoDirectionTypeEnum.AUTODIR_BASIC)] [PositionType(PositionTypeEnum.COLLISION_PLANE)] public class BeamConnection : ConnectionBase { private readonly StructuresData3 data; private readonly Model myModel; public BeamConnection(StructuresData3 data) { this.data = data; myModel = new Model(); } 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; } void CreateFitting(double thickness, ModelObject mySecondary) { 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 = mySecondary; 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 secondary Beam secondary = myModel.SelectModelObject(Secondaries[0]) as Beam; Point point1 = new Point(); Point point2 = new Point(); 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); this.CreateFitting(thickness, secondary); } 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