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 Autodesk.Revit.DB; using Autodesk.Revit.DB.Mechanical; using Autodesk.Revit.DB.Plumbing; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; namespace KMBIM.Revit.Tools.AvoidObstruction { public partial class FormAvoidObstruction : System.Windows.Forms.Form { public FormAvoidObstruction(ExternalCommandData data) { InitializeComponent(); m_rvtUIDoc = data.Application.ActiveUIDocument; m_rvtDoc = data.Application.ActiveUIDocument.Document; m_rvtApp = data.Application.Application; this.resolver = new Resolver(data); m_ListObstructionElement = new List(); m_ListAvoidanceElement = new List(); } // 충돌요소선택 private void buttonSelectObstructionElement_Click(object sender, EventArgs e) { // 선택한 패밀리요소로부터 파라미터를 복사합니다. try { List lstSelType = new List(); lstSelType.Add(typeof(Duct)); lstSelType.Add(typeof(Pipe)); //lstSelType.Add(typeof(CableTray)); //lstSelType.Add(typeof(Conduit)); string msg = Properties.Resources.SelectObstructionElement; var lstRef = m_rvtUIDoc.Selection.PickObjects(ObjectType.Element, new AvoidObstructionSelectionFilter(lstSelType), msg); if (lstRef != null) { foreach (var r in lstRef.ToList()) { Element e1 = m_rvtDoc.GetElement(r.ElementId); if (e != null) m_ListObstructionElement.Add(e1); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } // 회피요소 선택 private void buttonSelectAvoidElement_Click(object sender, EventArgs e) { resolver.SetAvoidObstructionType(this.m_AvoidObstructinType); // 선택한 패밀리요소로부터 파라미터를 복사합니다. try { string msg = Properties.Resources.SelectAvoidanceElement; List lstSelType = new List(); lstSelType.Add(typeof(Duct)); lstSelType.Add(typeof(Pipe)); //lstSelType.Add(typeof(CableTray)); //lstSelType.Add(typeof(Conduit)); var lstRef = m_rvtUIDoc.Selection.PickObjects(ObjectType.Element, new AvoidObstructionSelectionFilter(lstSelType), Properties.Resources.SelectObstructionElement); if (lstRef != null) { foreach (var r in lstRef.ToList()) { Element e1 = m_rvtDoc.GetElement(r.ElementId); if (e != null) m_ListAvoidanceElement.Add(e1); this.resolver.Resolve(ref m_ListObstructionElement, ref m_ListAvoidanceElement); } // 회피 기능 실행 } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void radioButtonUpDn_CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.AvoidUpDn; } private void radioButton_Up_CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.Avoid_Up; } private void radioButton_Dn_CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.Avoid_Dn; } private void radioButtonDnUp_CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.AvoidDnUp; } private void radioButtonUp__CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.AvoidUp_; } private void radioButtonDn__CheckedChanged(object sender, EventArgs e) { m_AvoidObstructinType = EnumAvoidObstructionType.AvoidDn_; } private void FormAvoidObstruction_Load(object sender, EventArgs e) { radioButtonUpDn.Checked = true; } } }