zhangyk-c
2024-07-11 9ca59ac2d37530208538a05a704b5ea712cab7db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HStation.RevitDev.RevitDataExport.Forms;
using Spire.AI.Api;
using System;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Windows.Controls;
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));
 
            //测试代码
            UIApplication uiapp = commandData.Application;
            Guid guid = new Guid(Common.GlobalResource.Guid_FamilyPanel);
            DockablePaneId paneId = new DockablePaneId(guid);
            DockablePane pane = uiapp.GetDockablePane(paneId);
            pane.Hide();
 
            return Result.Succeeded;
        }
    }
 
    [Transaction(TransactionMode.Manual)]
    public class PumpSystemAnalysis : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            TaskDialog.Show("提示","泵系统分析命令调用成功!");
            UIApplication uiapp = commandData.Application;
            Wpf_FamilyPanel page = new Wpf_FamilyPanel();
            Guid guid = Guid.Empty;
            guid = new Guid(Common.GlobalResource.Guid_FamilyPanel);
            DockablePaneId paneId = new DockablePaneId(guid);
            DockablePane pane = uiapp.GetDockablePane(paneId);
            pane.Show();
            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;
    }
}