| | |
| | | using Autodesk.Revit.DB; |
| | | using Autodesk.Revit.DB.Plumbing; |
| | | using Autodesk.Revit.UI; |
| | | using DevExpress.Utils.Extensions; |
| | | using Hydro.Core.Model; |
| | | using Hydro.Revit; |
| | | using Hydro.Revit.Model; |
| | | using HStation.RevitDev.RevitDataExport.Utility; |
| | | using HStation.RevitDev.RevitDataExport.Utils; |
| | | 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 HStation.RevitDev.RevitDataExport.Forms |
| | | { |
| | | public partial class Form_CheckResult : System.Windows.Forms.Form |
| | | { |
| | | private System.Windows.Forms.TabControl _pageContainer; |
| | | private Form_SystemSelect _form_SystemSelect; |
| | | private CheckModel model; |
| | | private UIDocument _uiDocument; |
| | | private Document _doc; |
| | | public Form_CheckResult(CheckModel checkModel, System.Windows.Forms.TabControl pageContainer, ExternalCommandData data, Form_SystemSelect form_SystemSelect) |
| | | { |
| | | _uiDocument = data.Application.ActiveUIDocument; |
| | | _doc = _uiDocument.Document; |
| | | _pageContainer = pageContainer; |
| | | _form_SystemSelect = form_SystemSelect; |
| | | this.model = checkModel; |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | private void Form_CheckResult_Load(object sender, EventArgs e) |
| | | { |
| | | dataGridView1.DataSource = model.FailList; |
| | | } |
| | | |
| | | private View3D Set3DView() |
| | | { |
| | | var view3d = ViewHelper.Get3dView(_doc); |
| | | _uiDocument.ActiveView = view3d; |
| | | return view3d; |
| | | } |
| | | |
| | | private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) |
| | | { |
| | | var rowIndex = e.RowIndex; |
| | | var columnIndex = e.ColumnIndex; |
| | | var cell = dataGridView1[columnIndex, rowIndex]; |
| | | |
| | | if (cell.Value == null) { return; } |
| | | var view = Set3DView(); |
| | | |
| | | var cellText = cell.Value.ToString(); |
| | | if (dataGridView1.Columns[columnIndex].HeaderText == "ID") |
| | | { |
| | | var idContent = cellText.Split(':')?.Last(); |
| | | if (string.IsNullOrEmpty(idContent)) { return; } |
| | | if (int.TryParse(idContent, out int id)) |
| | | { |
| | | if (!id.Equals(0)) |
| | | { |
| | | var elementId = new ElementId(id); |
| | | var ids = new List<ElementId> { elementId }; |
| | | view.Select(_uiDocument, ids); |
| | | view.Zoom(_uiDocument, ids); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void button1_Click(object sender, EventArgs e) |
| | | { |
| | | _form_SystemSelect.SetCheckIndexs(); |
| | | this.model = _form_SystemSelect.GetNetWrok(); |
| | | dataGridView1.Refresh(); |
| | | } |
| | | |
| | | private void ReCheck() |
| | | { |
| | | var nw = _form_SystemSelect._revitNetWork; |
| | | var mod = this.model; |
| | | if (checkBox1.Checked) //喷淋修复连接管件上游管道 |
| | | { |
| | | var ps = mod.FailList.Where(c => c.Type == Hydro.Core.ObjectEnum.FailType.喷头只能连接管道); |
| | | var ids = ps.Select(c => c.ID); |
| | | var ms = ps.Select(c => c.ID).ToArray(); |
| | | var nos = nw.Nozzles.Where(c => ids.Contains(c.ID)); |
| | | |
| | | nos.ForEach(c => |
| | | { |
| | | var gj = nw.Junctions.FirstOrDefault(b => b.ID == c.Node1); |
| | | if (gj != null) |
| | | { |
| | | var gjid = gj.ID; |
| | | var pipe = nw.Links.FirstOrDefault(b => b.Node1 == gjid || b.Node2 == gjid); |
| | | c.Node1 = pipe.ID; |
| | | if (pipe.Node1.Equals(gjid)) pipe.Node1 = c.ID; |
| | | if (pipe.Node2.Equals(gjid)) pipe.Node2 = c.ID; |
| | | } |
| | | }); |
| | | |
| | | for (var i = 0; i < ms.Count(); i++) |
| | | { |
| | | var m = mod.FailList.FirstOrDefault(c => c.ID == ms[i] && c.Type == Hydro.Core.ObjectEnum.FailType.喷头只能连接管道); |
| | | mod.FailList.Remove(m); |
| | | }; |
| | | |
| | | |
| | | } |
| | | if (checkBox2.Checked) //管道修改缺少一个连接对象,增加闷头(虚拟结点) |
| | | { |
| | | var pipes = nw.Pipes.Where(c => (c.Node1 + "_" + c.Node2).Length > 1 && (c.Node1 + "_" + c.Node2).Length < 10); |
| | | var ids = pipes.Select(c => c.ID); |
| | | var ms = mod.FailList.Where(c => ids.Contains(c.ID)).Select(c => c.ID).ToArray(); |
| | | for (var i = 0; i < ms.Count(); i++) |
| | | { |
| | | var m = mod.FailList.FirstOrDefault(c => c.ID == ms[i] && c.Type == Hydro.Core.ObjectEnum.FailType.缺少Node1或Node2连接属性); |
| | | mod.FailList.Remove(m); |
| | | } |
| | | |
| | | pipes.ForEach(c => |
| | | { |
| | | nw.AddJunction(new Hydro.Revit.Model.JunctionViewModel() |
| | | { |
| | | ID = "10000" + c.ID, |
| | | Name = "闷头", |
| | | Elev = 0, |
| | | PositionJson = c.PositionJson, |
| | | Floor = c.Floor, |
| | | SystemType = c.SystemType, |
| | | }); |
| | | if (string.IsNullOrEmpty(c.Node1)) c.Node1 = "10000" + c.ID; |
| | | if (string.IsNullOrEmpty(c.Node2)) c.Node2 = "10000" + c.ID; |
| | | }); |
| | | } |
| | | this.model.Result = !mod.FailList.Any(); |
| | | dataGridView1.DataSource = null; |
| | | dataGridView1.DataSource = this.model.FailList; |
| | | dataGridView1.Refresh(); |
| | | } |
| | | |
| | | private void button2_Click(object sender, EventArgs e) |
| | | { |
| | | //var j = JsonHelper.ReadJsonFile("d:\\revitMFire.json"); |
| | | //var r = JsonHelper.ToObject<NetWorkOutViewModel>(j); |
| | | ReCheck(); |
| | | |
| | | //if (this.model.Result) |
| | | //{ |
| | | var json = JsonHelper.ToJson(_form_SystemSelect._revitNetWork); |
| | | |
| | | JsonHelper.WriteJson("d:\\revitMFire.json", json); |
| | | _form_SystemSelect._revitNetWork.BuildToInp("d:\\mfire.inp"); |
| | | //} |
| | | // else |
| | | // MessageBox.Show("检验未通过,不能导出"); |
| | | |
| | | } |
| | | |
| | | private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | using Autodesk.Revit.DB;
|
| | | using Autodesk.Revit.UI;
|
| | | using DevExpress.Utils.Extensions;
|
| | | using Hydro.Core.Model;
|
| | | using HStation.RevitDev.RevitDataExport.Utility;
|
| | | using HStation.RevitDev.RevitDataExport.Common;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Data;
|
| | | using System.Linq;
|
| | | using System.Windows.Forms;
|
| | |
|
| | | namespace HStation.RevitDev.RevitDataExport.Forms
|
| | | {
|
| | | public partial class Form_CheckResult : System.Windows.Forms.Form
|
| | | {
|
| | | private System.Windows.Forms.TabControl _pageContainer;
|
| | | private Form_SystemSelect _form_SystemSelect;
|
| | | private CheckModel model;
|
| | | private UIDocument _uiDocument;
|
| | | private Document _doc;
|
| | | public Form_CheckResult(CheckModel checkModel, System.Windows.Forms.TabControl pageContainer, ExternalCommandData data, Form_SystemSelect form_SystemSelect)
|
| | | {
|
| | | _uiDocument = data.Application.ActiveUIDocument;
|
| | | _doc = _uiDocument.Document;
|
| | | _pageContainer = pageContainer;
|
| | | _form_SystemSelect = form_SystemSelect;
|
| | | this.model = checkModel;
|
| | | InitializeComponent();
|
| | | }
|
| | |
|
| | | private void Form_CheckResult_Load(object sender, EventArgs e)
|
| | | {
|
| | | dataGridView1.DataSource = model.FailList;
|
| | | }
|
| | |
|
| | | private View3D Set3DView()
|
| | | {
|
| | | var view3d = ViewHelper.Get3dView(_doc);
|
| | | _uiDocument.ActiveView = view3d;
|
| | | return view3d;
|
| | | }
|
| | |
|
| | | private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
| | | {
|
| | | var rowIndex = e.RowIndex;
|
| | | var columnIndex = e.ColumnIndex;
|
| | | var cell = dataGridView1[columnIndex, rowIndex];
|
| | |
|
| | | if (cell.Value == null) { return; }
|
| | | var view = Set3DView();
|
| | |
|
| | | var cellText = cell.Value.ToString();
|
| | | if (dataGridView1.Columns[columnIndex].HeaderText == "ID")
|
| | | {
|
| | | var idContent = cellText.Split(':')?.Last();
|
| | | if (string.IsNullOrEmpty(idContent)) { return; }
|
| | | if (int.TryParse(idContent, out int id))
|
| | | {
|
| | | if (!id.Equals(0))
|
| | | {
|
| | | var elementId = new ElementId(id);
|
| | | var ids = new List<ElementId> { elementId };
|
| | | view.Select(_uiDocument, ids);
|
| | | view.Zoom(_uiDocument, ids);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void button1_Click(object sender, EventArgs e)
|
| | | {
|
| | | _form_SystemSelect.SetCheckIndexs();
|
| | | this.model = _form_SystemSelect.GetNetWrok();
|
| | | dataGridView1.Refresh();
|
| | | }
|
| | |
|
| | | private void ReCheck()
|
| | | {
|
| | | var nw = _form_SystemSelect._revitNetWork;
|
| | | var mod = this.model;
|
| | | if (checkBox1.Checked) //喷淋修复连接管件上游管道
|
| | | {
|
| | | var ps = mod.FailList.Where(c => c.Type == Hydro.Core.ObjectEnum.FailType.喷头只能连接管道);
|
| | | var ids = ps.Select(c => c.ID);
|
| | | var ms = ps.Select(c => c.ID).ToArray();
|
| | | var nos = nw.Nozzles.Where(c => ids.Contains(c.ID));
|
| | |
|
| | | nos.ForEach(c =>
|
| | | {
|
| | | var gj = nw.Junctions.FirstOrDefault(b => b.ID == c.Node1);
|
| | | if (gj != null)
|
| | | {
|
| | | var gjid = gj.ID;
|
| | | var pipe = nw.Links.FirstOrDefault(b => b.Node1 == gjid || b.Node2 == gjid);
|
| | | c.Node1 = pipe.ID;
|
| | | if (pipe.Node1.Equals(gjid)) pipe.Node1 = c.ID;
|
| | | if (pipe.Node2.Equals(gjid)) pipe.Node2 = c.ID;
|
| | | }
|
| | | });
|
| | |
|
| | | for (var i = 0; i < ms.Count(); i++)
|
| | | {
|
| | | var m = mod.FailList.FirstOrDefault(c => c.ID == ms[i] && c.Type == Hydro.Core.ObjectEnum.FailType.喷头只能连接管道);
|
| | | mod.FailList.Remove(m);
|
| | | };
|
| | |
|
| | |
|
| | | }
|
| | | if (checkBox2.Checked) //管道修改缺少一个连接对象,增加闷头(虚拟结点)
|
| | | {
|
| | | var pipes = nw.Pipes.Where(c => (c.Node1 + "_" + c.Node2).Length > 1 && (c.Node1 + "_" + c.Node2).Length < 10);
|
| | | var ids = pipes.Select(c => c.ID);
|
| | | var ms = mod.FailList.Where(c => ids.Contains(c.ID)).Select(c => c.ID).ToArray();
|
| | | for (var i = 0; i < ms.Count(); i++)
|
| | | {
|
| | | var m = mod.FailList.FirstOrDefault(c => c.ID == ms[i] && c.Type == Hydro.Core.ObjectEnum.FailType.缺少Node1或Node2连接属性);
|
| | | mod.FailList.Remove(m);
|
| | | }
|
| | |
|
| | | pipes.ForEach(c =>
|
| | | {
|
| | | nw.AddJunction(new Hydro.Revit.Model.JunctionViewModel()
|
| | | {
|
| | | ID = "10000" + c.ID,
|
| | | Name = "闷头",
|
| | | Elev = 0,
|
| | | PositionJson = c.PositionJson,
|
| | | Floor = c.Floor,
|
| | | SystemType = c.SystemType,
|
| | | });
|
| | | if (string.IsNullOrEmpty(c.Node1)) c.Node1 = "10000" + c.ID;
|
| | | if (string.IsNullOrEmpty(c.Node2)) c.Node2 = "10000" + c.ID;
|
| | | });
|
| | | }
|
| | | this.model.Result = !mod.FailList.Any();
|
| | | dataGridView1.DataSource = null;
|
| | | dataGridView1.DataSource = this.model.FailList;
|
| | | dataGridView1.Refresh();
|
| | | }
|
| | |
|
| | | private void button2_Click(object sender, EventArgs e)
|
| | | {
|
| | | //var j = JsonHelper.ReadJsonFile("d:\\revitMFire.json");
|
| | | //var r = JsonHelper.ToObject<NetWorkOutViewModel>(j);
|
| | | ReCheck();
|
| | |
|
| | | //if (this.model.Result)
|
| | | //{
|
| | | var json = JsonHelper.ToJson(_form_SystemSelect._revitNetWork);
|
| | |
|
| | | JsonHelper.WriteJson("d:\\revitMFire.json", json);
|
| | | _form_SystemSelect._revitNetWork.BuildToInp("d:\\mfire.inp");
|
| | | //}
|
| | | // else
|
| | | // MessageBox.Show("检验未通过,不能导出");
|
| | |
|
| | | }
|
| | |
|
| | | private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|