1
+ //
2
+ // Revit Batch Processor
3
+ //
4
+ // Copyright (c) 2020 Daniel Rumery, BVN
5
+ //
6
+ // This program is free software: you can redistribute it and/or modify
7
+ // it under the terms of the GNU General Public License as published by
8
+ // the Free Software Foundation, either version 3 of the License, or
9
+ // (at your option) any later version.
10
+ //
11
+ // This program is distributed in the hope that it will be useful,
12
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ // GNU General Public License for more details.
15
+ //
16
+ // You should have received a copy of the GNU General Public License
17
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ //
19
+ //
20
+
21
+ using System ;
22
+ using System . ComponentModel ;
23
+ using System . IO ;
24
+ using Autodesk . Revit . ApplicationServices ;
25
+ using Autodesk . Revit . Attributes ;
26
+ using Autodesk . Revit . UI ;
27
+ using BatchRvt . ScriptHost ;
28
+ using WinForms = System . Windows . Forms ;
29
+
30
+ namespace BatchRvt . Addin . Revit2025
31
+ {
32
+ [ Transaction ( TransactionMode . Manual ) ]
33
+ [ Regeneration ( RegenerationOption . Manual ) ]
34
+ [ DisplayName ( "BatchRvtAddin" ) ]
35
+ [ Description ( "BatchRvtAddin" ) ]
36
+ public class BatchRvtAddinApplication : IExternalApplication
37
+ {
38
+ public Result OnStartup ( UIControlledApplication uiApplication )
39
+ {
40
+ SetupBatchScriptHost ( uiApplication . ControlledApplication ) ;
41
+
42
+ return Result . Succeeded ;
43
+ }
44
+
45
+ public Result OnShutdown ( UIControlledApplication application )
46
+ {
47
+ return Result . Succeeded ;
48
+ }
49
+
50
+ private static void SetupBatchScriptHost ( ControlledApplication controlledApplication )
51
+ {
52
+ var pluginFolderPath = Path . GetDirectoryName ( typeof ( BatchRvtAddinApplication ) . Assembly . Location ) ;
53
+
54
+ var batchRvtExternalEventHandler = new BatchRvtExternalEventHandler ( pluginFolderPath ) ;
55
+
56
+ batchRvtExternalEventHandler . Raise ( ) ;
57
+ }
58
+ }
59
+
60
+ public class BatchRvtExternalEventHandler : IExternalEventHandler
61
+ {
62
+ private readonly ExternalEvent externalEvent_ ;
63
+ private readonly string pluginFolderPath_ ;
64
+
65
+ public BatchRvtExternalEventHandler ( string pluginFolderPath )
66
+ {
67
+ externalEvent_ = ExternalEvent . Create ( this ) ;
68
+ pluginFolderPath_ = pluginFolderPath ;
69
+ }
70
+
71
+ public void Execute ( UIApplication uiApp )
72
+ {
73
+ try
74
+ {
75
+ ScriptHostUtil . ExecuteBatchScriptHost ( pluginFolderPath_ , uiApp ) ;
76
+ }
77
+ catch ( Exception e )
78
+ {
79
+ WinForms . MessageBox . Show ( e . ToString ( ) , ScriptHostUtil . BATCH_RVT_ERROR_WINDOW_TITLE ) ;
80
+ }
81
+ }
82
+
83
+ public string GetName ( )
84
+ {
85
+ return "BatchRvt_ExternalEventHandler" ;
86
+ }
87
+
88
+ public ExternalEventRequest Raise ( )
89
+ {
90
+ return externalEvent_ . Raise ( ) ;
91
+ }
92
+ }
93
+ }
0 commit comments