IDE:Visual Studio 2019
TEKLA:2022
创建一个.net Framework窗体应用程序,添加一个按钮:
using System;
using System.Collections;
using System.Windows.Forms;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model;
namespace Exercise
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MyModel = new Model();
}
private readonly Model MyModel;
private void button2_Click(object sender, EventArgs e)
{
if (MyModel.GetConnectionStatus())
{
var p1 = new Point(0, 0, 0);
var p2 = new Point(0, 0, 5000);
var p3 = new Point(0, 5000, 6000);
var p4 = new Point(0, 7000, 0);
Contour contour = new Contour();
contour.AddContourPoint(new ContourPoint(p1, new Chamfer()));
contour.AddContourPoint(new ContourPoint(p2, new Chamfer()));
contour.AddContourPoint(new ContourPoint(p3, new Chamfer()));
contour.AddContourPoint(new ContourPoint(p4, new Chamfer()));
ContourPlate contourPlate = new ContourPlate();
contourPlate.Contour = contour;
contourPlate.Profile.ProfileString = "500";
contourPlate.Material.MaterialString = "S235JR";
contourPlate.Insert();
MyModel.CommitChanges();
ArrayList reportPropertiesNames = new ArrayList()
{
"WEIGHT",
"AREA",
"LENGTH"
};
var hashTable = new Hashtable();
contourPlate.GetDoubleReportProperties(reportPropertiesNames, ref hashTable);
Console.WriteLine("Contour plate inserterd. Id: " + contourPlate.Identifier.ID);
Console.WriteLine("Report properties:");
foreach (var key in hashTable.Keys)
{
Console.WriteLine($"Report property: {key} = {hashTable[key]}");
}
}
}
}
}