using Autodesk.Revit.Attributes;
|
using Autodesk.Revit.DB;
|
using Autodesk.Revit.UI;
|
using HStation.RevitDev.RevitDataExport.Forms;
|
using System;
|
using System.Diagnostics;
|
using System.Drawing.Drawing2D;
|
using System.Windows.Forms;
|
|
namespace HStation.RevitDev.RevitDataExport
|
{
|
[Transaction(TransactionMode.Manual)]
|
public class Export : IExternalCommand
|
{
|
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
{
|
var form = new Form_SystemSelect(commandData);
|
//var revitHandle = Autodesk.Windows.ComponentManager.ApplicationWindow;
|
|
//实例WPF窗体
|
var revitHandle = Process.GetCurrentProcess().MainWindowHandle;
|
form.Show(new WindowHandle(revitHandle));
|
|
|
return Result.Succeeded;
|
}
|
}
|
|
public class WindowHandle : IWin32Window
|
{
|
private IntPtr _handle;
|
|
public WindowHandle(IntPtr h)
|
{
|
Debug.Assert(IntPtr.Zero != h, "expected non-null window handle");
|
|
_handle = h;
|
}
|
public IntPtr Handle => _handle;
|
}
|
}
|