| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using Autodesk.AutoCAD.DatabaseServices;
- 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;
-
- namespace CADTools
- {
- public partial class PtLinecontradiction : Form
- {
- public PtLinecontradiction()
- {
- InitializeComponent();
- }
-
- private void PtLinecontradiction_Load(object sender, EventArgs e)
- {
- //自动填充下拉框
- Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
- //存放所有图层名
- List<string> alllayername = new List<string>();
- LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
- foreach (ObjectId objid in layertable)
- {
- LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
- alllayername.Add(layertablerecord.Name);
- }
- alllayername.Sort();
-
- for (int i = 0; i < alllayername.Count; i++)
- {
- this.comboBox_ElePoint.Items.Add(alllayername[i]);
- this.comboBox_sqx.Items.Add(alllayername[i]);
- this.comboBox_jqx.Items.Add(alllayername[i]);
- }
-
- if (alllayername.Contains("8300"))
- {
- int index = alllayername.IndexOf("8300");
- this.comboBox_ElePoint.SelectedIndex = index;
- }
- if (alllayername.Contains("8110"))
- {
- int index = alllayername.IndexOf("8110");
- this.comboBox_sqx.SelectedIndex = index;
- }
- if (alllayername.Contains("8120"))
- {
- int index = alllayername.IndexOf("8120");
- this.comboBox_jqx.SelectedIndex = index;
- }
- traction.Commit();
- }
- }
-
- private void btn_OK_Click(object sender, EventArgs e)
- {
- if (comboBox_ElePoint.Text == "")
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择高程点图层");
- return;
- }
- if (comboBox_blc.Text == "")
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
- return;
- }
- if (comboBox_sqx.Text == "")
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线图层");
- return;
- }
- if (comboBox_jqx.Text == "")
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线图层");
- return;
- }
- if (string.IsNullOrWhiteSpace(textBox_dgj.Text))
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请输入等高距");
- return;
- }
- double.TryParse(textBox_dgj.Text, out double number);
- if (number <= 0)
- {
- Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("等高距不能为0或负数");
- return;
- }
-
- ChPLContradiction1.elevationLayer = comboBox_ElePoint.Text;
- ChPLContradiction1.sqx = comboBox_sqx.Text;
- ChPLContradiction1.jqx = comboBox_jqx.Text;
- ChPLContradiction1.dgj = Convert.ToDouble(textBox_dgj.Text.Trim());
-
-
- //比例尺
- string blctext = comboBox_blc.Text;
- int blcindex = blctext.LastIndexOf(':');
- string strblc = blctext.Substring(blcindex + 1);
- int intblc = Convert.ToInt32(strblc);
- ChPLContradiction1.blc = intblc;
-
- ChPLContradiction1 chplc = new ChPLContradiction1();
- chplc.Check();
- this.Close();
- MessageBox.Show("点线矛盾检查完成。\n共有"+ ChPLContradiction1.num + "个异常点。");
- }
-
- private void btn_Cancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|