Skip to content

Commit 9cbf721

Browse files
committed
Added 2026 version
1 parent a0dbb10 commit 9cbf721

219 files changed

Lines changed: 157926 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2026_DirectManipulationPlugins.Examples/BasicPlugin/BasicPlugin.csproj

Lines changed: 253 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
namespace BasicPlugin
2+
{
3+
using System;
4+
using System.Collections;
5+
using System.Collections.Generic;
6+
7+
using Tekla.Structures.Geometry3d;
8+
using Tekla.Structures.Model.UI;
9+
using Tekla.Structures.Plugins;
10+
11+
using TSM = Tekla.Structures.Model;
12+
13+
/// <summary>
14+
/// This class is used for storing data related to the current plugin.
15+
/// </summary>
16+
public class StructuresData
17+
{
18+
/// <summary>
19+
/// The length factor.
20+
/// </summary>
21+
[StructuresField("LengthFactor")]
22+
public double LengthFactor;
23+
24+
/// <summary>
25+
/// The profile.
26+
/// </summary>
27+
[StructuresField("Profile")]
28+
public string Profile;
29+
}
30+
31+
/// <summary>
32+
/// This plugin is similar to the example found in the Open API Reference PluginBase section.
33+
/// The plugin asks the user to pick two points. The plug-in then calculates new insertion points
34+
/// using a double parameter from the dialog and creates a beam.
35+
/// </summary>
36+
[Plugin(PluginName)]
37+
[PluginUserInterface("BasicPlugin.BeamPluginForm")]
38+
public class BeamPlugin : PluginBase
39+
{
40+
/// <summary>
41+
/// Gets the structures data.
42+
/// </summary>
43+
private StructuresData Data { get; }
44+
45+
/// <summary>
46+
/// The current length factor.
47+
/// </summary>
48+
private double lengthFactor;
49+
50+
/// <summary>
51+
/// The current profile.
52+
/// </summary>
53+
private string profile;
54+
55+
/// <summary>
56+
/// The default profile name.
57+
/// </summary>
58+
public static readonly string DefaultProfileName = "HEA300";
59+
60+
/// <summary>
61+
/// The name of the plugin. This value is used in the attribute above as well as with the Direct Manipulation creation and manipulation features.
62+
/// </summary>
63+
public const string PluginName = "Beam Plugin Example";
64+
65+
/// <summary>
66+
/// Initializes a new instance of the <see cref="BeamPlugin"/> class.
67+
/// </summary>
68+
/// <param name="data">The <see cref="StructuresData"/> object for the plugin.</param>
69+
public BeamPlugin(StructuresData data)
70+
{
71+
this.Data = data;
72+
}
73+
74+
/// <inheritdoc />
75+
public override bool Run(List<InputDefinition> input)
76+
{
77+
try
78+
{
79+
this.GetValuesFromDialog();
80+
81+
var points = (ArrayList)input[0].GetInput();
82+
var point1 = points[0] as Point;
83+
var point2 = points[1] as Point;
84+
var lengthVector = new Vector(point2 - point1);
85+
86+
if (this.lengthFactor > 0)
87+
{
88+
point2 = this.lengthFactor * lengthVector + point1;
89+
}
90+
91+
this.CreateBeam(point1, point2);
92+
}
93+
catch (Exception ex)
94+
{
95+
Console.WriteLine(@"Exception: " + ex);
96+
}
97+
98+
return true;
99+
}
100+
101+
/// <inheritdoc />
102+
public override List<InputDefinition> DefineInput()
103+
{
104+
var beamPicker = new Picker();
105+
var pointList = new List<InputDefinition>();
106+
107+
var point1 = beamPicker.PickPoint();
108+
var point2 = beamPicker.PickPoint();
109+
110+
var input1 = new InputDefinition(point1);
111+
var input2 = new InputDefinition(point2);
112+
113+
pointList.Add(input1);
114+
pointList.Add(input2);
115+
116+
return pointList;
117+
}
118+
119+
/// <summary>
120+
/// Gets the current values from dialog.
121+
/// </summary>
122+
private void GetValuesFromDialog()
123+
{
124+
this.lengthFactor = this.Data.LengthFactor;
125+
this.profile = this.Data.Profile;
126+
if (this.IsDefaultValue(this.lengthFactor))
127+
{
128+
this.lengthFactor = 2.0;
129+
}
130+
131+
if (this.IsDefaultValue(this.profile))
132+
{
133+
this.profile = DefaultProfileName;
134+
}
135+
}
136+
137+
/// <summary>
138+
/// Creates a beam using two input points.
139+
/// </summary>
140+
/// <param name="point1">The first input point.</param>
141+
/// <param name="point2">The second input point.</param>
142+
private void CreateBeam(Point point1, Point point2)
143+
{
144+
var myBeam = new TSM.Beam(point1, point2)
145+
{
146+
Profile = { ProfileString = this.profile },
147+
Finish = "PAINT"
148+
};
149+
150+
myBeam.Class = "2";
151+
myBeam.Material.MaterialString = "Steel_Undefined";
152+
myBeam.Name = "MyBeam";
153+
154+
myBeam.Insert();
155+
}
156+
}
157+
}

2026_DirectManipulationPlugins.Examples/BasicPlugin/BeamPluginForm.Designer.cs

Lines changed: 148 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
namespace BasicPlugin
2+
{
3+
using System;
4+
using Tekla.Structures.Dialog;
5+
6+
/// <summary>
7+
/// This class uses the <seealso cref="PluginFormBase"/> class to define the user interface as a Windows Forms dialog.
8+
/// </summary>
9+
public partial class BeamPluginForm : PluginFormBase
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="BeamPluginForm"/> class.
13+
/// </summary>
14+
public BeamPluginForm()
15+
{
16+
this.InitializeComponent();
17+
}
18+
19+
/// <inheritdoc />
20+
protected override string LoadValuesPath(string fileName)
21+
{
22+
this.SetAttributeValue(this.textBoxLengthFactor, 2d); // One line for each plugin attribute
23+
this.SetAttributeValue(this.textBoxProfile, BeamPlugin.DefaultProfileName);
24+
var result = base.LoadValuesPath(fileName);
25+
this.Apply();
26+
return result;
27+
}
28+
29+
/// <summary>
30+
/// Handles the ApplyClicked event of the okApplyModifyGetOnOffCancel1 control.
31+
/// </summary>
32+
/// <param name="sender">The source of the event.</param>
33+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
34+
private void OkApplyModifyGetOnOffCancel1_ApplyClicked(object sender, EventArgs e)
35+
{
36+
this.Apply();
37+
}
38+
39+
/// <summary>
40+
/// Handles the CancelClicked event of the okApplyModifyGetOnOffCancel1 control.
41+
/// </summary>
42+
/// <param name="sender">The source of the event.</param>
43+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
44+
private void OkApplyModifyGetOnOffCancel1_CancelClicked(object sender, EventArgs e)
45+
{
46+
this.Close();
47+
}
48+
49+
/// <summary>
50+
/// Handles the GetClicked event of the okApplyModifyGetOnOffCancel1 control.
51+
/// </summary>
52+
/// <param name="sender">The source of the event.</param>
53+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
54+
private void OkApplyModifyGetOnOffCancel1_GetClicked(object sender, EventArgs e)
55+
{
56+
this.Get();
57+
}
58+
59+
/// <summary>
60+
/// Handles the ModifyClicked event of the okApplyModifyGetOnOffCancel1 control.
61+
/// </summary>
62+
/// <param name="sender">The source of the event.</param>
63+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
64+
private void OkApplyModifyGetOnOffCancel1_ModifyClicked(object sender, EventArgs e)
65+
{
66+
this.Modify();
67+
}
68+
69+
/// <summary>
70+
/// Handles the OkClicked event of the okApplyModifyGetOnOffCancel1 control.
71+
/// </summary>
72+
/// <param name="sender">The source of the event.</param>
73+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
74+
private void OkApplyModifyGetOnOffCancel1_OkClicked(object sender, EventArgs e)
75+
{
76+
this.Apply();
77+
this.Close();
78+
}
79+
80+
/// <summary>
81+
/// Handles the OnOffClicked event of the okApplyModifyGetOnOffCancel1 control.
82+
/// </summary>
83+
/// <param name="sender">The source of the event.</param>
84+
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
85+
private void OkApplyModifyGetOnOffCancel1_OnOffClicked(object sender, EventArgs e)
86+
{
87+
this.ToggleSelection();
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)