Client/Desktop/KMBIM3.0/23.10.16/Cmd/PipeConnection/RequestHandlerPipeConnect.cs

94 lines
2.7 KiB
C#

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
{
/// <summary>
/// 대화상자에서의 요청을 실행한다.
/// </summary>
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();
/// <summary>
/// A public property to access the current request value
/// </summary>
public RequestForPipeConnect Request
{
get { return m_request; }
}
/// <summary>
/// A method to identify this External Event Handler
/// </summary>
public String GetName()
{
return "KMBIM External Event Handler";
}
/// <summary>
/// The top method of the event handler.
/// </summary>
/// <remarks>
/// 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)
/// </remarks>
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
}