基本信息
源码名称:C# 创建三角网项目(AutoCAD)
源码大小:0.23M
文件格式:.zip
开发语言:C#
更新时间:2019-05-28
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Data.OleDb;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
namespace TriangulationNetwork
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void draw_Click(object sender, EventArgs e)
{
//选中当前文档里面的所有点
DBObjectCollection points = new DBObjectCollection();
points = Methods.SelectAllPoint();
Point3dCollection pt = new Point3dCollection();
foreach (DBPoint item in points)
{
pt.Add(item.Position);
}
//ConvexHull hull = new ConvexHull(pt);
//hull.CalculateConvex();
TriNet triNet = new TriNet(pt);
triNet.CalculateTriNet();
}
/// <summary>
/// 读取EXCEL文档在CAD上画点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ExcelBtn_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "打开excel文档";
openFileDialog1.Filter = "Excle 文件(*.xls)|*xls";
this.openFileDialog1.FileName = "";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName; //文档路径
string connection = "Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=" path
";" "Extended Properties='Excel 8.0;HDR=yes;IMEX=1';";
string select = "Select * from [sheet1$]";
OleDbConnection oleDdConn = new OleDbConnection();
try
{
oleDdConn = new OleDbConnection(connection);
oleDdConn.Open();
OleDbCommand command = new OleDbCommand(select, oleDdConn);
OleDbDataReader read = command.ExecuteReader();
while (read.Read())
{
//读取表格中的值
string X = read.GetValue(1).ToString();
string Y = read.GetValue(2).ToString();
string Z = read.GetValue(3).ToString();
//转换为数字
double x = Convert.ToDouble(X);
double y = Convert.ToDouble(Y);
double z = Convert.ToDouble(Z);
DrawGeom.DrawDBPoint(x, y, z);
}
}
catch (Exception)
{
MessageBox.Show("读入错误");
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}