using Autodesk.Revit.DB; using Autodesk.Revit.UI; using KMBIM.Revit.Tools.Cmd.PipeConnection; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KMBIM.Revit.Tools.Cmd.Piping { /// /// 대화상자에서의 요청을 실행한다. /// public class RequestHandlerPipeConnect : IExternalEventHandler { // A trivial delegate, but handy private delegate void DoorOperation(FamilyInstance e); // The value of the latest request made by the modeless form private RequestForPipeConnect m_request = new RequestForPipeConnect(); /// /// A public property to access the current request value /// public RequestForPipeConnect Request { get { return m_request; } } /// /// A method to identify this External Event Handler /// public String GetName() { return "KMBIM External Event Handler"; } /// /// The top method of the event handler. /// /// /// This is called by Revit after the corresponding /// external event was raised (by the modeless form) /// and Revit reached the time at which it could call /// the event's handler (i.e. this object) /// public void Execute(UIApplication uiapp) { UIDocument uidoc = uiapp.ActiveUIDocument; try { ResolverForPipeConnect resolver = Request.Take(); if (resolver != null) { if (uidoc != null) { using (TransactionGroup trans = new TransactionGroup(uidoc.Document, "Pipe Connect")) { try { trans.Start(); resolver.Run(); trans.Commit(); } catch (Exception ex) { trans.RollBack(); System.Windows.Forms.MessageBox.Show(ex.Message); } } } } } finally { App.thisApp.WakeFormPipeConnector(); } return; } }//end-class }