using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tekla.Structures;
using TSM = Tekla.Structures.Model;
using T3D = Tekla.Structures.Geometry3d;
using TSUI = Tekla.Structures.Model.UI;
using Tekla.Structures.Model;
using System.Reflection;
namespace tekla_WFApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCreateBeams_Click(object sender, EventArgs e)
{
TSM.Model model = new TSM.Model();
if (model.GetConnectionStatus())
{
var tmp = txtBeams.Text.Split('*');
var qty = Convert.ToInt16(tmp[0]);
var dist =Convert.ToDouble(tmp[1]);
for (int i = 0; i <= qty; i++)
{
var ptS = new T3D.Point(i*dist, 0, 0);
var ptE = new T3D.Point(i*dist,6000*(i+1),0);
TSM.Beam b = new TSM.Beam(ptS,ptE);
b.Profile.ProfileString = "HN400*200*8*13";
b.Class = "3";
b.Material.MaterialString="Q235B";
b.Insert();
}
model.CommitChanges();
MessageBox.Show("建立成功");
}
}
private void button1_Click(object sender, EventArgs e)
{
TSM.Model model = new TSM.Model();
if (model.GetConnectionStatus())
{
// 圆的参数设置
double radius = 5000; // 圆半径(毫米)
T3D.Point center = new T3D.Point(5000, 5000, 0); // 圆心位置
int numberOfPoints = 12; // 点数
// 存储所有点位置的列表
List<T3D.Point> points = new List<T3D.Point>();
// 计算圆周上的点位置
for (int i = 0; i < numberOfPoints; i++)
{
double angle = 2 * Math.PI * i / numberOfPoints; // 计算角度(弧度)
double x = center.X + radius * Math.Cos(angle);
double y = center.Y + radius * Math.Sin(angle);
points.Add(new T3D.Point(x, y, center.Z));
}
// 两两连接所有点
for (int i = 0; i < numberOfPoints; i++)
{
for (int j = i + 1; j < numberOfPoints; j++)
{
// 创建连接两个点的梁
TSM.Beam beam = new TSM.Beam(points[i], points[j]);
beam.Profile.ProfileString = "HN400*200*8*13";
beam.Class = "3";
beam.Material.MaterialString = "Q235B";
beam.Position.Rotation = Position.RotationEnum.TOP; // 设置梁的旋转方向
beam.Insert();
}
}
model.CommitChanges();
MessageBox.Show($"成功创建{numberOfPoints}个点及其两两连接梁");
}
else
{
MessageBox.Show("无法连接到Tekla模型");
}
}
}
}
在tekla软件上进行二次开发,显示这样一种效果
最新推荐文章于 2025-08-05 20:53:10 发布